From: David Disseldorp <ddiss@suse.de>
To: linux-kbuild@vger.kernel.org
Cc: David Disseldorp <ddiss@suse.de>
Subject: [PATCH v2 2/2] scripts: headers_install: avoid extra sed call for license check
Date: Thu, 8 Jan 2026 07:39:43 +1100 [thread overview]
Message-ID: <20260107205239.6390-3-ddiss@suse.de> (raw)
In-Reply-To: <20260107205239.6390-1-ddiss@suse.de>
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>
---
| 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
--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}
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
scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
[ $? -gt 1 ] && exit 1
--
2.51.0
next prev parent reply other threads:[~2026-01-07 20:52 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 ` David Disseldorp [this message]
2026-01-21 11:34 ` [PATCH v2 2/2] scripts: headers_install: avoid extra sed call for license check Nicolas Schier
2026-01-29 12:27 ` David Disseldorp
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=20260107205239.6390-3-ddiss@suse.de \
--to=ddiss@suse.de \
--cc=linux-kbuild@vger.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