lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5f95bede9603416ca9f1c6ee17d54b35@intel.com>
Date:   Tue, 29 Sep 2020 14:40:23 +0000
From:   "Rojewski, Cezary" <cezary.rojewski@...el.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Andrew Morton" <akpm@...ux-foundation.org>
Subject: Re: [PATCH v2] list: Add a macro to test if entry is pointing to the
 head

On 2020-09-29 3:43 PM, Andy Shevchenko wrote:
> Add a macro to test if entry is pointing to the head of the list
> which is useful in cases like:
> 
>    list_for_each_entry(pos, &head, member) {
>      if (cond)
>        break;
>    }
>    if (list_entry_is_head(pos, &head, member))
>      return -ERRNO;
> 
> that allows to avoid additional variable to be added to track if loop
> has not been stopped in the middle.
> 
> While here, convert list_for_each_entry*() family of macros to use a new one.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
> v2: converted users inside list.h, dropped ambiguous description

Reviewed-by: Cezary Rojewski <cezary.rojewski@...el.com>

This is a good addition to the list of helper macros found in list.h.

When looking at below:

>   /**
>    * list_for_each_entry	-	iterate over list of given type
>    * @pos:	the type * to use as a loop cursor.
> @@ -617,7 +626,7 @@ static inline void list_splice_tail_init(struct list_head *list,
>    */
>   #define list_for_each_entry(pos, head, member)				\
>   	for (pos = list_first_entry(head, typeof(*pos), member);	\
> -	     &pos->member != (head);					\
> +	     !list_entry_is_head(pos, head, member);			\
>   	     pos = list_next_entry(pos, member))
>   

it seems such helper should have been here a long time ago (notice the
usage of helpers for initial assignment and cursor update while the
loop-exit check was devoid of such).

Czarek

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ