cstyle: understand macro params can be empty

It's not uncommon to have empty parameters in code generator macros,
usually when multiple parameters are concatenated or stringified into a
single token or literal. So, exclude the space-before-comma check, which
will allow construction like `MACRO_CALL(foo, , baz)`.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes #16840
This commit is contained in:
Rob Norris 2024-12-04 17:55:32 +11:00 committed by Brian Behlendorf
parent 903895ea5f
commit ba00a6f9a3

View File

@ -572,7 +572,9 @@ line: while (<$filehandle>) {
err("comma or semicolon followed by non-blank"); err("comma or semicolon followed by non-blank");
} }
# allow "for" statements to have empty "while" clauses # allow "for" statements to have empty "while" clauses
if (/\s[,;]/ && !/^[\t]+;$/ && !/^\s*for \([^;]*; ;[^;]*\)/) { # allow macro invocations to have empty parameters
if (/\s[,;]/ && !/^[\t]+;$/ &&
!($in_macro_call || /^\s*for \([^;]*; ;[^;]*\)/)) {
err("comma or semicolon preceded by blank"); err("comma or semicolon preceded by blank");
} }
if (/^\s*(&&|\|\|)/) { if (/^\s*(&&|\|\|)/) {