Skip to content

Commit ba00a6f

Browse files
robnbehlendorf
authored andcommitted
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 <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes #16840
1 parent 903895e commit ba00a6f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scripts/cstyle.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,9 @@ ($$)
572572
err("comma or semicolon followed by non-blank");
573573
}
574574
# allow "for" statements to have empty "while" clauses
575-
if (/\s[,;]/ && !/^[\t]+;$/ && !/^\s*for \([^;]*; ;[^;]*\)/) {
575+
# allow macro invocations to have empty parameters
576+
if (/\s[,;]/ && !/^[\t]+;$/ &&
577+
!($in_macro_call || /^\s*for \([^;]*; ;[^;]*\)/)) {
576578
err("comma or semicolon preceded by blank");
577579
}
578580
if (/^\s*(&&|\|\|)/) {

0 commit comments

Comments
 (0)