Skip to contentSkip to conversation

scripts: headers_install: avoid some reprocessing

RFC PATCH Superseded David Disseldorp 3 participants 9 messages Nov 11, 2025 – Jan 7 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover scripts: headers_install: avoid some reprocessing

scripts/headers_install.sh is relatively inefficient: it parses/modifies headers via unifdef and three sed invocations, with sed output post-processed via grep in one case (user-space CONFIG_ leaks).

These patches attempt to improve efficiency by merging two sed calls and processing user-space CONFIG_ leak filters inline.

Unfortunately my parallel / sync headers_install benchmarks didn't show meaningful performance improvements, hence the RFC tag.

Output is unaffected. License and CONFIG leak checks have been manually tested via error injection.

David Disseldorp (3):
scripts: headers_install: move config_leak_ignores assignment
scripts: headers_install: filter ignored configs via sed
scripts: headers_install: avoid license check fork

 scripts/headers_install.sh | 85 ++++++++++++++++++--------------------
 1 file changed, 40 insertions(+), 45 deletions(-)
#1 lore raw

RFC PATCH 1/3 scripts: headers_install: move config_leak_ignores assignment

In preparation for skipping ignored configs within the sed script itself, rather than output post-processing.

---
 scripts/headers_install.sh | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
scripts/headers_install.sh +16 -16
index 4c20c62c4faf5..d64b01806a05e 100755
@@ -38,6 +38,22 @@ sed -E -e '
 	s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @
 ' $INFILE > $TMPFILE || exit 1
 
+# The entries in the following list do not result in an error.
+# Please do not add a new entry. This list is only for existing ones.
+# The list will be reduced gradually, and deleted eventually. (hopefully)
+#
+# The format is <file-name>:<CONFIG-option> in each line.
+config_leak_ignores="
+arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K
+arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K
+arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE
+arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
+arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
+arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
+arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION
+arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64
+"
+
 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
 [ $? -gt 1 ] && exit 1
 
@@ -64,22 +80,6 @@ configs=$(sed -e '
 	d
 ' $OUTFILE)
 
-# The entries in the following list do not result in an error.
-# Please do not add a new entry. This list is only for existing ones.
-# The list will be reduced gradually, and deleted eventually. (hopefully)
-#
-# The format is <file-name>:<CONFIG-option> in each line.
-config_leak_ignores="
-arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K
-arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K
-arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE
-arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
-arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
-arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
-arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION
-arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64
-"
-
 for c in $configs
 do
 	leak_error=1
Signature · 1 line
2.51.0
#2 lore raw

RFC PATCH 2/3 scripts: headers_install: filter ignored configs via sed

In reply to David Disseldorp

The sed script currently prints any CONFIG_ entries carried in installed headers. A subsequent shell script parses this output to check whether the found CONFIG_ values should be ignored or not.

Drop the unnecessary sed output post-processing and instead skip over ignored CONFIG_ values as part of initial processing.

---
 scripts/headers_install.sh | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)
scripts/headers_install.sh +12 -22
index d64b01806a05e..f46e91aa416cf 100755
@@ -54,11 +54,16 @@ arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION
 arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64
 "
 
+# generate sed regex to filter out ignored configs.
+# A subsequent 't' branches if any of these filters match.
+sed_filter_ignores=$(echo "$config_leak_ignores" \
+	| sed -ne "s@$INFILE:\(.*\)"'@\ts:^\1\\n::@p')
+
 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
 [ $? -gt 1 ] && exit 1
 
 # Remove /* ... */ style comments, and find CONFIG_ references in code
-configs=$(sed -e '
+sed -e '
 :comment
 	s:/\*[^*][^*]*:/*:
 	s:/\*\*\**\([^/]\):/*\1:
@@ -68,9 +73,12 @@ configs=$(sed -e '
 	/\/\*/! b check
 	N
 	b comment
-:print
+:print'"
+	$sed_filter_ignores
+	t check
+	s@^\(.*\)\n.*@error: $INFILE leak \1 to user-space@
 	P
-	D
+	Q2"'
 :check
 	s:^\(CONFIG_[[:alnum:]_]*\):\1\n:
 	t print
@@ -78,25 +86,7 @@ configs=$(sed -e '
 	s:^[^[:alnum:]_][^[:alnum:]_]*::
 	t check
 	d
-' $OUTFILE)
-
-for c in $configs
-do
-	leak_error=1
-
-	for ignore in $config_leak_ignores
-	do
-		if echo "$INFILE:$c" | grep -q "$ignore$"; then
-			leak_error=
-			break
-		fi
-	done
-
-	if [ "$leak_error" = 1 ]; then
-		echo "error: $INFILE: leak $c to user-space" >&2
-		exit 1
-	fi
-done
+' $OUTFILE >&2 || exit 1
 
 rm -f $TMPFILE
 trap - EXIT
Signature · 1 line
2.51.0
#3 lore raw

Re: [RFC PATCH 2/3] scripts: headers_install: filter ignored configs via sed

kernel test robot noticed the following build errors:

Hi David,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on masahiroy-kbuild/for-next masahiroy-kbuild/fixes v6.18-rc5] [cannot apply to next-20251113]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/David-Disseldorp/scripts-headers_install-move-config_leak_ignores-assignment/20251111-212423
base:   linus/master
patch link:    https://lore.kernel.org/r/20251111132021.22809-3-ddiss%40suse.de
patch subject: [RFC PATCH 2/3] scripts: headers_install: filter ignored configs via sed
config: arc-randconfig-001-20251114 (https://download.01.org/0day-ci/archive/20251114/[email protected]/config)
compiler: arc-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251114/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> error: arch/arc/include/uapi/asm/swab.h leak CONFIG_ARC_HAS_SWAPE to user-space

make[3]: *** [scripts/Makefile.headersinst:63: usr/include/asm/swab.h] Error 1 shuffle=3877595197 make[3]: Target '__headers' not remade because of errors.
make[2]: *** [Makefile:1379: headers] Error 2 shuffle=3877595197
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:248: __sub-make] Error 2 shuffle=3877595197
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:248: __sub-make] Error 2 shuffle=3877595197
make: Target 'prepare' not remade because of errors.

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#4 lore raw

Re: [RFC PATCH 2/3] scripts: headers_install: filter ignored configs via sed

On Fri, 14 Nov 2025 14:47:35 +0800, kernel test robot wrote:
...

Quoted 1 line
Quoted 1 line
Quoted 1 line

error: arch/arc/include/uapi/asm/swab.h leak CONFIG_ARC_HAS_SWAPE to user-space

Thanks for the report. I'm unfortunately unable to reproduce this. Can you provide version details for the shell and sed versions on the test system? I didn't find them in the links above.

Also, the shell "set -x" output for the failing headers_install.sh invocation would be helpful.
E.g.
bash -x ./scripts/headers_install.sh \
arch/arc/include/uapi/asm/swab.h /tmp/debug_swab.h

#5 lore raw

Re: [RFC PATCH 2/3] scripts: headers_install: filter ignored configs via sed

hi, David Disseldorp,

Quoted 7 lines · David Disseldorp

On Fri, 14 Nov 2025 14:47:35 +0800, kernel test robot wrote:
...

Quoted 1 line
Quoted 1 line
Quoted 1 line

error: arch/arc/include/uapi/asm/swab.h leak CONFIG_ARC_HAS_SWAPE to user-space

Thanks for the report. I'm unfortunately unable to reproduce this. Can you provide version details for the shell and sed versions on the test system? I didn't find them in the links above.

this issue can be reproduced by below shell/sed version

xsang@xsang-OptiPlex-9020:~/kernel-upstream/linux$ bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
xsang@xsang-OptiPlex-9020:~/kernel-upstream/linux$ sed --version
sed (GNU sed) 4.8
Quoted 6 lines

Also, the shell "set -x" output for the failing headers_install.sh invocation would be helpful.
E.g.
bash -x ./scripts/headers_install.sh \
arch/arc/include/uapi/asm/swab.h /tmp/debug_swab.h

I make below change

scripts/Makefile.headersinst +1 -1
index 029d85bb0b23..9f33733e35d5 100644
@@ -57,7 +57,7 @@ $(if $(new-dirs), $(shell mkdir -p $(new-dirs)))
 
 # Rules
 quiet_cmd_install = HDRINST $@
-      cmd_install = $(CONFIG_SHELL) $(srctree)/scripts/headers_install.sh $< $@
+      cmd_install = $(CONFIG_SHELL) -x $(srctree)/scripts/headers_install.sh $< $@
 
 $(src-headers): $(dst)/%.h: $(src)/%.h $(srctree)/scripts/headers_install.sh FORCE
        $(call if_changed,install)

then see below output by following the reproducer [1]

xsang@xsang-OptiPlex-9020:~/kernel-upstream/linux$ COMPILER_INSTALL_PATH=/home/xsang/cross-compiler/ COMPILER=gcc-8.5.0 ~/lkp-tests/kbuild/make.cross W=1 O=build_dir ARCH=arc prepare
Compiler will be installed in /home/xsang/cross-compiler/
PATH=/home/xsang/.local/bin:/home/xsang/bin:/home/xsang/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/xsang/.local/bin
make --keep-going CONFIG_OF_ALL_DTBS=y CONFIG_DTC=y CROSS_COMPILE=/home/xsang/cross-compiler//gcc-8.5.0-nolibc/arc-linux/bin/arc-linux- --jobs=72 KCFLAGS= -Wno-error=return-type -Wreturn-type -funsigned-char -Wundef W=1 O=build_dir ARCH=arc prepare
make[1]: Entering directory '/home/xsang/kernel-upstream/linux/build_dir'
  GEN     Makefile
  HDRINST usr/include/asm/swab.h
+ [ 2 -ne 2 ]
+ INFILE=../arch/arc/include/uapi/asm/swab.h
+ OUTFILE=usr/include/asm/swab.h
+ TMPFILE=usr/include/asm/swab.h.tmp
+ trap rm -f $OUTFILE $TMPFILE EXIT
+ sed -n -e /SPDX-License-Identifier:.*GPL-/{/WITH Linux-syscall-note/!p} ../arch/arc/include/uapi/asm/swab.h
+ [ -n  ]
+ sed -E -e
        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 @
 ../arch/arc/include/uapi/asm/swab.h
+ config_leak_ignores=
arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K
arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K
arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE
arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION
arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64

+ echo arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8 arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64

+ sed -ne s@../arch/arc/include/uapi/asm/swab.h:\(.*\)@\ts:^\1\\n::@p
+ sed_filter_ignores=
+ scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ usr/include/asm/swab.h.tmp
+ [ 0 -gt 1 ]
+ sed -e
:comment

        s:/\*[^*][^*]*:/*:
        s:/\*\*\**\([^/]\):/*\1:
        t comment
        s:/\*\*/: :
        t comment
        /\/\*/! b check
        N
        b comment

:print

        t check
        s@^\(.*\)\n.*@error: ../arch/arc/include/uapi/asm/swab.h leak \1 to user-space@
        P
        Q2
:check
        s:^\(CONFIG_[[:alnum:]_]*\):\1\n:
        t print
        s:^[[:alnum:]_][[:alnum:]_]*::
        s:^[^[:alnum:]_][^[:alnum:]_]*::
        t check
        d

usr/include/asm/swab.h
error: ../arch/arc/include/uapi/asm/swab.h leak CONFIG_ARC_HAS_SWAPE to user-space
+ exit 1
+ rm -f usr/include/asm/swab.h usr/include/asm/swab.h.tmp
make[3]: *** [../scripts/Makefile.headersinst:63: usr/include/asm/swab.h] Error 1 make[3]: Target '__headers' not remade because of errors.
make[2]: *** [/home/xsang/kernel-upstream/linux/Makefile:1379: headers] Error 2
CALL ../scripts/checksyscalls.sh
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [/home/xsang/kernel-upstream/linux/Makefile:248: __sub-make] Error 2 make[1]: Target 'prepare' not remade because of errors.
make[1]: Leaving directory '/home/xsang/kernel-upstream/linux/build_dir'
make: *** [Makefile:248: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.

[1]
https://download.01.org/0day-ci/archive/20251114/[email protected]/reproduce

#6 lore raw

Re: [RFC PATCH 2/3] scripts: headers_install: filter ignored configs via sed

[revisiting an old thread]

Quoted 34 lines · Oliver Sang

+ INFILE=../arch/arc/include/uapi/asm/swab.h
+ OUTFILE=usr/include/asm/swab.h
+ TMPFILE=usr/include/asm/swab.h.tmp
+ trap rm -f $OUTFILE $TMPFILE EXIT
+ sed -n -e /SPDX-License-Identifier:.*GPL-/{/WITH Linux-syscall-note/!p} ../arch/arc/include/uapi/asm/swab.h
+ [ -n ]
+ sed -E -e

        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 @

../arch/arc/include/uapi/asm/swab.h
+ config_leak_ignores= arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8 arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64

+ echo arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8 arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64

Quoted 2 lines

+ sed -ne s@../arch/arc/include/uapi/asm/swab.h:\(.*\)@\ts:^\1\\n::@p
+ sed_filter_ignores=

Thanks a lot for providing the extra details here, Oliver. make headers_install with O=build_dir sees INFILE carry a '../' prefix, which stops the sed_filter_ignores regex from matching. Prior to this change the post processing grep accepted such prefixes:
if echo "$INFILE:$c" | grep -q "$ignore$"; then

I've sent a v2 patch which accepts INFILE prefixes when checking against ignored configs.

Cheers, David

#7 lore raw

Re: [RFC PATCH 2/3] scripts: headers_install: filter ignored configs via sed

In reply to David Disseldorp
kernel test robot noticed the following build errors:

Hi David,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.18-rc5]
[cannot apply to next-20251113]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/David-Disseldorp/scripts-headers_install-move-config_leak_ignores-assignment/20251111-212423
base:   linus/master
patch link:    https://lore.kernel.org/r/20251111132021.22809-3-ddiss%40suse.de
patch subject: [RFC PATCH 2/3] scripts: headers_install: filter ignored configs via sed
config: arm-randconfig-004-20251114 (https://download.01.org/0day-ci/archive/20251114/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 0bba1e76581bad04e7d7f09f5115ae5e2989e0d9)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251114/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> error: arch/arm/include/uapi/asm/ptrace.h leak CONFIG_CPU_ENDIAN_BE8 to user-space

make[3]: *** [scripts/Makefile.headersinst:63: usr/include/asm/ptrace.h] Error 1 shuffle=2824370977 make[3]: Target '__headers' not remade because of errors.
make[2]: *** [Makefile:1379: headers] Error 2 shuffle=2824370977
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:248: __sub-make] Error 2 shuffle=2824370977
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:248: __sub-make] Error 2 shuffle=2824370977
make: Target 'prepare' not remade because of errors.

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#8 lore raw

RFC PATCH 3/3 scripts: headers_install: avoid license check fork

In reply to David Disseldorp

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.

---
 scripts/headers_install.sh | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
scripts/headers_install.sh +12 -7
index f46e91aa416cf..7dbb8eb6f0a0b 100755
@@ -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
 
 # The entries in the following list do not result in an error.
 # Please do not add a new entry. This list is only for existing ones.
Signature · 1 line
2.51.0