Re: [PATCH 6/6] checkpatch.pl: generalize linker script macro exceptions

From: jim . cromie

Date: Mon Nov 23 2026 - 13:15:53 EST


On Sat, Nov 21, 2026 at 7:27 PM Joe Perches <joe@xxxxxxxxxxx> wrote:
>
> On Sat, 2026-11-21 at 15:49 -0700, Jim Cromie via B4 Relay wrote:
> > From: Jim Cromie <jim.cromie@xxxxxxxxx>
> >
> > checkpatch skips macro-rule checks in linker scripts; 3 of them
> > explicitly check for vmlinux.lds.h, and 1 (the 1st) skips on any
> > *.lds.h. Generalize the 3 to match the 1st, including the escapes on
> > the dots, so they're literal checks for '.'
>
> Please remember to email the checkpatch maintainer too.

ack.
I missed that b4 prep -c didnt add you.

>
> >
> > Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
> > ---
> > scripts/checkpatch.pl | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index b8b64f720191..318e1f2577fd 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -6016,7 +6016,7 @@ sub process {
> > # Usually multi-statement macros should be enclosed in a do {} while
> > # (0) loop. Grab the first statement and ensure its the whole macro
> > # if its not enclosed in a known good container
> > - if ($realfile !~ m@/vmlinux.lds.h$@ &&
> > + if ($realfile !~ m@/\.lds\.h$@ &&
>
> Probably better to have something like
> my $is_linker_file = '\.lds\.h$';
> or maybe
> my $is_linker_file = '\Q.lds.h\E$';
>
> and use that everywhere

yup.

>
> > @@ -6175,7 +6175,7 @@ sub process {
> >
> > # check for line continuations outside of #defines, preprocessor #, and asm
> >
> > - } elsif ($realfile =~ m@/vmlinux.lds.h$@) {
> > + } elsif ($realfile =~ m@/\.lds\.h$@) {
>
> > $line =~ s/(\w+)/$maybe_linker_symbol{$1}++/ge;
> > #print "REAL: $realfile\nln: $line\nkeys:", sort keys %maybe_linker_symbol;
> > } else {
> > @@ -6192,7 +6192,7 @@ sub process {
> > # single-statement macros do not need to be enclosed in do while (0) loop,
> > # macro should not end with a semicolon
> > if ($perl_version_ok &&
> > - $realfile !~ m@/vmlinux.lds.h$@ &&
> > + $realfile !~ m@/\.lds\.h$@ &&
> > $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) {
> > my $ln = $linenr;
> > my $cnt = $realcnt;