[PATCH 1/1] checkpatch: allow multi-statement declarative macros.

From: Jim Cromie
Date: Thu May 16 2024 - 10:14:38 EST


Declarative macros, which declare/define storage (at either file or
function scope), cannot be wrapped in do-while statements. So
checkpatch advice is incorrect here.

The code has an $exceptions regex which allows multiple statements
based on the macro name, etc; /DECLARE_PER_CPU|DEFINE_PER_CPU/ are
currently accepted, widen those to accept /DECLARE|DEFINE/.

cc: Andy Whitcroft <apw@xxxxxxxxxxxxx> # (maintainer:CHECKPATCH)
cc: Joe Perches <joe@xxxxxxxxxxx> # (maintainer:CHECKPATCH)
cc: Dwaipayan Ray <dwaipayanray1@xxxxxxxxx> # (reviewer:CHECKPATCH)
cc: Lukas Bulwahn <lukas.bulwahn@xxxxxxxxx> # (reviewer:CHECKPATCH)
Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
---
scripts/checkpatch.pl | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 9c4c4a61bc83..cddf4c416523 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5901,6 +5901,7 @@ sub process {
}
}

+# except for declarative macros (whether file or function scope),
# multi-statement macros should be enclosed in a do while loop, grab the
# first statement and ensure its the whole macro if its not enclosed
# in a known good container
@@ -5958,8 +5959,8 @@ sub process {
$Declare|
module_param_named|
MODULE_PARM_DESC|
- DECLARE_PER_CPU|
- DEFINE_PER_CPU|
+ DECLARE|
+ DEFINE|
__typeof__\(|
union|
struct|
--
2.45.0