Skip to content

Commit

Permalink
cstyle: understand macro params can be empty
Browse files Browse the repository at this point in the history
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 openzfs#16840
  • Loading branch information
robn authored and behlendorf committed Dec 6, 2024
1 parent 0e87150 commit 87947f2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scripts/cstyle.pl
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,9 @@ ($$)
err("comma or semicolon followed by non-blank");
}
# 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");
}
if (/^\s*(&&|\|\|)/) {
Expand Down

0 comments on commit 87947f2

Please sign in to comment.