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 <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes #16840
  • Loading branch information
robn authored and behlendorf committed Dec 6, 2024
1 parent 903895e commit ba00a6f
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 ba00a6f

Please sign in to comment.