public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: David Disseldorp <ddiss@suse.de>
To: Nicolas Schier <nsc@kernel.org>
Cc: linux-kbuild@vger.kernel.org, Nathan Chancellor <nathan@kernel.org>
Subject: Re: [PATCH v2 2/2] scripts: headers_install: avoid extra sed call for license check
Date: Thu, 29 Jan 2026 23:27:10 +1100	[thread overview]
Message-ID: <20260129232710.31078980.ddiss@suse.de> (raw)
In-Reply-To: <aXC52UIHjmsNJG4B@derry.ads.avm.de>

Thanks for the review Nicolas...

On Wed, 21 Jan 2026 12:34:49 +0100, Nicolas Schier wrote:

> [Cc+=nathan]
> 
> On Thu, Jan 08, 2026 at 07:39:43AM +1100, David Disseldorp wrote:
> > headers_install runs a sed script to check that any GPL variant
> > SPDX-License-Identifier line carries a "WITH Linux-syscall-note".
> > A subsequent sed invocation then handles removal of a few things that
> > aren't desired in installed headers (e.g. __attribute_const__).
> > 
> > Combine these two sed scripts to avoid re-processing the same file.
> > License check errors, as opposed to write errors, are indicated via a
> > special sed exit status of 9.
> > 
> > Signed-off-by: David Disseldorp <ddiss@suse.de>
> > ---
> >  scripts/headers_install.sh | 19 ++++++++++++-------
> >  1 file changed, 12 insertions(+), 7 deletions(-)
> > 
> > diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
> > index 2181abd1c9b70..ef952cbbb8fde 100755
> > --- a/scripts/headers_install.sh
> > +++ b/scripts/headers_install.sh
> > @@ -23,20 +23,25 @@ TMPFILE=$OUTFILE.tmp
> >  
> >  trap 'rm -f $OUTFILE $TMPFILE' EXIT
> >  
> > -# SPDX-License-Identifier with GPL variants must have "WITH Linux-syscall-note"
> > -if [ -n "$(sed -n -e "/SPDX-License-Identifier:.*GPL-/{/WITH Linux-syscall-note/!p}" $INFILE)" ]; then
> > -	echo "error: $INFILE: missing \"WITH Linux-syscall-note\" for SPDX-License-Identifier" >&2
> > -	exit 1
> > -fi
> > -
> > +# returns 9 if GPL SPDX-License-Identifier omits "WITH Linux-syscall-note"
> >  sed -E -e '
> > +	/SPDX-License-Identifier:.*GPL-/{/WITH Linux-syscall-note/! Q9}  
> 
> thanks, I like the idea of combining the sed calls.  According to the
> manual 'Q' (or 'q' with argument) is a GNU extension (non-POSIX).
> 
> May we expect GNU sed on all system running headers_install?

Good catch. 
I suspect there might already be some GNU sed specific code, based on
LKL's explicit use of gsed for builds on BSD hosts:
https://github.com/lkl/linux/commit/84f39699a6d1013d1866b8637977804e515d8d7e
I don't have any proof for mainline though (yet).

> >  	s/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g
> >  	s/__attribute_const__([[:space:]]|$)/\1/g
> >  	s@^#include <linux/compiler.h>@@
> >  	s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
> >  	s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
> >  	s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @
> > -' $INFILE > $TMPFILE || exit 1
> > +' $INFILE > $TMPFILE
> > +case $? in
> > +9)
> > +	echo "error: $INFILE: missing \"WITH Linux-syscall-note\" for SPDX-License-Identifier" >&2
> > +	exit 1
> > +	;;
> > +1)
> > +	exit 1
> > +	;;
> > +esac  
> 
> This silently ignores all other exit codes.  What about this:
> 
> 9)
> ...
> 	;;
> 0)	;;
> *)
> 	exit 1
> 	;;
> esac

Ack, I see that 2 and 4 returns are also possible. Your fix looks good
to me.
I'll squash it in and resend if I find any other GNU sed specific code.
Otherwise this change can probably be dropped.

Cheers, David

  reply	other threads:[~2026-01-29 12:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07 20:39 [PATCH v2 0/2] scripts: headers_install: avoid some reprocessing David Disseldorp
2026-01-07 20:39 ` [PATCH v2 1/2] scripts: headers_install: filter ignored configs via sed David Disseldorp
2026-01-12 10:51   ` Thomas Weißschuh
2026-01-12 11:14     ` David Disseldorp
2026-01-07 20:39 ` [PATCH v2 2/2] scripts: headers_install: avoid extra sed call for license check David Disseldorp
2026-01-21 11:34   ` Nicolas Schier
2026-01-29 12:27     ` David Disseldorp [this message]
2026-01-08  8:38 ` [PATCH v2 0/2] scripts: headers_install: avoid some reprocessing David Disseldorp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260129232710.31078980.ddiss@suse.de \
    --to=ddiss@suse.de \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox