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


Groups > linux.kernel > #1477003

Re: [PATCH] RDS: Simplify code

From "santosh.shilimkar@oracle.com" <santosh.shilimkar@oracle.com>
Newsgroups linux.kernel
Subject Re: [PATCH] RDS: Simplify code
Date 2016-09-06 02:30 +0200
Message-ID <secr0-2Nf-3@gated-at.bofh.it> (permalink)
References <sdbQm-19P-7@gated-at.bofh.it> <sdEIF-7Fj-1@gated-at.bofh.it> <sdI9z-7Xv-1@gated-at.bofh.it> <sdKl5-We-77@gated-at.bofh.it>
Organization Oracle Corporation

Show all headers | View raw


On 9/4/16 11:23 AM, Leon Romanovsky wrote:
> On Sun, Sep 04, 2016 at 05:57:20PM +0200, Christophe JAILLET wrote:
>> Le 04/09/2016 à 14:20, Leon Romanovsky a écrit :
>>> 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.
>>>
>> You are right but if you dig further you will see that calling
>> INIT_LIST_HEAD on an empty list is a no-op (AFAIK).
>> And if this list was not already correctly initialized, then you would have
>> some other troubles.
>
> Thank you for the suggestion,
> It looks like the code after that can be skipped in case of loop_conns
> list is empty, the tmp_list will be empty too.
>
> 174         list_for_each_entry_safe(lc, _lc, &tmp_list, loop_node) {
> 175                 WARN_ON(lc->conn->c_passive);
> 176                 rds_conn_destroy(lc->conn);
> 177         }
>

Thanks for trying. As already pointed, your change doesn't simplify
much rather change the behavior. The loop cursor already takes care
of list empty case. I don't see any reason to change that code.

Regards,
Santosh

Back to linux.kernel | Previous | NextPrevious 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