Re: [PATCH 07/13] ptrlist: remove extra ident level

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 11/06/18 02:51, Luc Van Oostenryck wrote:
> The list walking macros are relatively complex and the code they define
> have often 5 or 6 level of nesting.
> 
> However, in a few places, a small rewrite of the code can save one
> nesting level and this help to make the code more readable.
> 
> Make this change and reduce the indentation level.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  ptrlist.h | 65 ++++++++++++++++++++++++++-----------------------------
>  1 file changed, 31 insertions(+), 34 deletions(-)
> 
> diff --git a/ptrlist.h b/ptrlist.h
> index 037fe28ff..c28abce6d 100644
> --- a/ptrlist.h
> +++ b/ptrlist.h
> @@ -157,44 +157,42 @@ static inline void *last_ptr_list(struct ptr_list *list)
>  #define DO_FOR_EACH(head, ptr, __head, __list, __nr, PTR_ENTRY) do {			\
>  	__typeof__(head) __head = head;							\
>  	__typeof__(head) __list = head;							\
> -	if (__head) {									\
> -		do { int __nr;								\
> -			for (__nr = 0; __nr < __list->nr; __nr++) {			\
> -				do {							\
> -					ptr = PTR_ENTRY(__list,__nr);			\
> -					if (__list->rm && !ptr)				\
> -						continue;				\
> -					do {
> +	if (!__head) break;								\

This patch is difficult to read (not your fault), so I will
only say that I think it is correct. ;-)

Again, not your fault, but it is not helped by this pattern:

> +	do { int __nr;									\
> +		for (__nr = 0; __nr < __list->nr; __nr++) {				\

... which declares the __nr variable on the 'do {' line. This case
is not the worst, but it throws off the indentation level, for the
sake of saving one line! :(

ATB,
Ramsay Jones
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux