Messages in this thread | | | Subject | Re: [PATCH RFC] checkpatch: fix multi-statement macro checks | From | Joe Perches <> | Date | Thu, 01 Oct 2020 06:17:21 -0700 |
| |
On Thu, 2020-10-01 at 16:03 +0530, Dwaipayan Ray wrote: > Checkpatch.pl doesn't have a check for excluding while (...) {...} > blocks from MULTISTATEMENT_MACRO_USE_DO_WHILE error. > > For example, running checkpatch.pl on the file mm/access.c in the > kernel generates the following error: > > ERROR: Macros with complex values should be enclosed in parentheses > +#define copy_from_kernel_nofault_loop(dst, src, len, type, err_label) \ > + while (len >= sizeof(type)) { \ > + __get_kernel_nofault(dst, src, type, err_label); \ > + dst += sizeof(type); \ > + src += sizeof(type); \ > + len -= sizeof(type); \ > + } > > The error is misleading for this case. Enclosing it in parantheses > doesn't make any sense.
OK
> Checkpatch already has an exception list for such common macro types. > Added a new exception for while (...) {...} style blocks to the same. > This effectively fixed the wrong error message. [] > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -5342,6 +5342,7 @@ sub process { > $dstat !~ /^\.$Ident\s*=/ && # .foo = > $dstat !~ /^(?:\#\s*$Ident|\#\s*$Constant)\s*$/ && # stringification #foo > $dstat !~ /^do\s*$Constant\s*while\s*$Constant;?$/ && # do {...} while (...); // do {...} while (...) > + $dstat !~ /^while\s*$Constant\s*$Constant\s*$/ && # while (...) {...}
Did you try to output $dstat for some matching cases? What was the $dstat value for the cases you tried?
| |