From ba00a6f9a3961876cbaacf5e4534efdbe2c9ff47 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 4 Dec 2024 17:55:32 +1100 Subject: [PATCH] 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 Signed-off-by: Rob Norris Closes #16840 --- scripts/cstyle.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/cstyle.pl b/scripts/cstyle.pl index 680ce97666b0..5483c3fe7c8a 100755 --- a/scripts/cstyle.pl +++ b/scripts/cstyle.pl @@ -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*(&&|\|\|)/) {