Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1475932

Re: [PATCH] RDS: Simplify code

From Leon Romanovsky <leon@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH] RDS: Simplify code
Date 2016-09-04 14:30 +0200
Message-ID <sdEIF-7Fj-1@gated-at.bofh.it> (permalink)
References <sdbQm-19P-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Sat, Sep 03, 2016 at 07:33:29AM +0200, Christophe JAILLET wrote:
> Calling 'list_splice' followed by 'INIT_LIST_HEAD' is equivalent to
> 'list_splice_init'.

It is not 100% accurate

list_splice(y, z)
INIT_LIST_HEAD(y)

==>

if (!list_empty(y))
     __list_splice(y, z, z>next);
INIT_LIST_HEAD(y)

and not

if (!list_empty(y)) {
     __list_splice(y, z, z>next);
     INIT_LIST_HEAD(y)
}

as list_splice_init will do.


>
> This has been spotted with the following coccinelle script:
> /////
> @@
> expression y,z;
> @@
>
> -   list_splice(y,z);
> -   INIT_LIST_HEAD(y);
> +   list_splice_init(y,z);
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  net/rds/loop.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/rds/loop.c b/net/rds/loop.c
> index f2bf78de5688..c3e6da4fdf97 100644
> --- a/net/rds/loop.c
> +++ b/net/rds/loop.c
> @@ -167,8 +167,7 @@ void rds_loop_exit(void)
>
>  	/* avoid calling conn_destroy with irqs off */
>  	spin_lock_irq(&loop_conns_lock);
> -	list_splice(&loop_conns, &tmp_list);
> -	INIT_LIST_HEAD(&loop_conns);
> +	list_splice_init(&loop_conns, &tmp_list);
>  	spin_unlock_irq(&loop_conns_lock);
>
>  	list_for_each_entry_safe(lc, _lc, &tmp_list, loop_node) {
> --
> 2.7.4
>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] RDS: Simplify code Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-09-03 07:40 +0200
  Re: [PATCH] RDS: Simplify code Leon Romanovsky <leon@kernel.org> - 2016-09-04 14:30 +0200
    Re: [PATCH] RDS: Simplify code Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-09-04 18:10 +0200
      Re: [PATCH] RDS: Simplify code Leon Romanovsky <leon@kernel.org> - 2016-09-04 20:30 +0200
        Re: [PATCH] RDS: Simplify code Leon Romanovsky <leon@kernel.org> - 2016-09-05 07:20 +0200
        Re: [PATCH] RDS: Simplify code "santosh.shilimkar@oracle.com" <santosh.shilimkar@oracle.com> - 2016-09-06 02:30 +0200

csiph-web