checkpatch: allow multi-statement declarative macros.
PATCH 1/1 checkpatch: allow multi-statement declarative macros.
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/.
--- scripts/checkpatch.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +3 -2
@@ -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|
Signature · 1 line
2.45.0
Joe Perches
maintainerQuoted 7 lines · Jim Cromie
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/.
It seems this exempts too large a number of these macros
$ git grep -P '^\s*\#\s*define\s+\w*(?:DECLARE|DEFINE)\w*'|wc -l 5075
How about somehow limiting these exemptions more strictly?
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0
[]
Quoted 19 lines
scripts/checkpatch.pl +3
-2@@ -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|
Quoted 6 lines · Joe Perches
Quoted 4 lines · Jim Cromie
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.
Quoted 9 lines
Quoted 3 lines
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/.
It seems this exempts too large a number of these macros
$ git grep -P '^\s*\#\s*define\s+\w*(?:DECLARE|DEFINE)\w*'|wc -l 5075
wow, thats more than Id have thought.
Quoted 1 line
How about somehow limiting these exemptions more strictly?
agreed. I'll just add my 1 exceptional macro name. resending shortly.
Joe Perches
maintainerQuoted 17 lines · On Thu, 2024-05-16 at 09:20 -0600, [email protected] wrote:
Quoted 6 lines · Joe Perches
Quoted 4 lines · Jim Cromie
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.
Quoted 9 lines
Quoted 3 lines
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/.
It seems this exempts too large a number of these macros
$ git grep -P '^\s*\#\s*define\s+\w*(?:DECLARE|DEFINE)\w*'|wc -l 5075
Quoted 6 lines
wow, thats more than Id have thought.
Quoted 1 line
How about somehow limiting these exemptions more strictly?
agreed. I'll just add my 1 exceptional macro name. resending shortly.
Is this macro used in a lot of places? Otherwise, why not just ignore the macro where it occurs?