All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: santosh.shilimkar@oracle.com, davem@davemloft.net,
	linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] RDS: Simplify code
Date: Sun, 04 Sep 2016 12:20:49 +0000	[thread overview]
Message-ID: <20160904122049.GQ21847@leon.nu> (raw)
In-Reply-To: <1472880809-29216-1-git-send-email-christophe.jaillet@wanadoo.fr>

[-- Attachment #1: Type: text/plain, Size: 1267 bytes --]

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
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Leon Romanovsky <leon@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: santosh.shilimkar@oracle.com, davem@davemloft.net,
	linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] RDS: Simplify code
Date: Sun, 4 Sep 2016 15:20:49 +0300	[thread overview]
Message-ID: <20160904122049.GQ21847@leon.nu> (raw)
In-Reply-To: <1472880809-29216-1-git-send-email-christophe.jaillet@wanadoo.fr>

[-- Attachment #1: Type: text/plain, Size: 1267 bytes --]

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
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-09-04 12:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-03  5:33 [PATCH] RDS: Simplify code Christophe JAILLET
2016-09-03  5:33 ` Christophe JAILLET
2016-09-03  5:33 ` Christophe JAILLET
2016-09-04 12:20 ` Leon Romanovsky [this message]
2016-09-04 12:20   ` Leon Romanovsky
2016-09-04 15:57   ` Christophe JAILLET
2016-09-04 15:57     ` Christophe JAILLET
     [not found]     ` <befa1a39-cfc5-721f-e39a-369436237b1c-39ZsbGIQGT5GWvitb5QawA@public.gmane.org>
2016-09-04 18:23       ` Leon Romanovsky
2016-09-04 18:23         ` Leon Romanovsky
2016-09-04 18:23         ` Leon Romanovsky
     [not found]         ` <20160904182354.GR21847-2ukJVAZIZ/Y@public.gmane.org>
2016-09-05  4:38           ` Christophe JAILLET
2016-09-05  5:14             ` Leon Romanovsky
2016-09-05  5:14               ` Leon Romanovsky
2016-09-06  0:22           ` santosh.shilimkar
2016-09-06  0:22             ` santosh.shilimkar
2016-09-06  0:22             ` santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160904122049.GQ21847@leon.nu \
    --to=leon@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=santosh.shilimkar@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.