* [PATCH 1/1] checkpatch: allow multi-statement declarative macros.
@ 2024-05-16 14:14 Jim Cromie
2024-05-16 14:43 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Jim Cromie @ 2024-05-16 14:14 UTC (permalink / raw)
To: linux-kernel
Cc: akpm, Jim Cromie, Andy Whitcroft, Joe Perches, Dwaipayan Ray,
Lukas Bulwahn
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@canonical.com> # (maintainer:CHECKPATCH)
cc: Joe Perches <joe@perches.com> # (maintainer:CHECKPATCH)
cc: Dwaipayan Ray <dwaipayanray1@gmail.com> # (reviewer:CHECKPATCH)
cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> # (reviewer:CHECKPATCH)
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] checkpatch: allow multi-statement declarative macros.
2024-05-16 14:14 [PATCH 1/1] checkpatch: allow multi-statement declarative macros Jim Cromie
@ 2024-05-16 14:43 ` Joe Perches
2024-05-16 15:20 ` jim.cromie
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2024-05-16 14:43 UTC (permalink / raw)
To: Jim Cromie, linux-kernel
Cc: akpm, Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn
On Thu, 2024-05-16 at 08:14 -0600, Jim Cromie wrote:
> 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?
> diff --git 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|
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] checkpatch: allow multi-statement declarative macros.
2024-05-16 14:43 ` Joe Perches
@ 2024-05-16 15:20 ` jim.cromie
2024-05-17 0:37 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: jim.cromie @ 2024-05-16 15:20 UTC (permalink / raw)
To: Joe Perches
Cc: linux-kernel, akpm, Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn
On Thu, May 16, 2024 at 8:43 AM Joe Perches <joe@perches.com> wrote:
>
> On Thu, 2024-05-16 at 08:14 -0600, Jim Cromie wrote:
> > 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
>
wow, thats more than Id have thought.
> How about somehow limiting these exemptions more strictly?
agreed. I'll just add my 1 exceptional macro name.
resending shortly.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] checkpatch: allow multi-statement declarative macros.
2024-05-16 15:20 ` jim.cromie
@ 2024-05-17 0:37 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2024-05-17 0:37 UTC (permalink / raw)
To: jim.cromie
Cc: linux-kernel, akpm, Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn
On Thu, 2024-05-16 at 09:20 -0600, jim.cromie@gmail.com wrote:
> On Thu, May 16, 2024 at 8:43 AM Joe Perches <joe@perches.com> wrote:
> >
> > On Thu, 2024-05-16 at 08:14 -0600, Jim Cromie wrote:
> > > 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
> >
>
> wow, thats more than Id have thought.
>
> > 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?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-17 0:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-16 14:14 [PATCH 1/1] checkpatch: allow multi-statement declarative macros Jim Cromie
2024-05-16 14:43 ` Joe Perches
2024-05-16 15:20 ` jim.cromie
2024-05-17 0:37 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox