linux/scripts
Yujie Liu 91f950e8b9 scripts/kernel-doc: match -Werror flag strictly
In our CI testing, we use some commands as below to only turn a specific
type of warnings into errors, but we notice that kernel-doc warnings
are also turned into errors unexpectedly.

$ make KCFLAGS="-Werror=return-type" W=1 kernel/fork.o

kernel/fork.c:1406: warning: Function parameter or member 'mm' not described in 'set_mm_exe_file'
kernel/fork.c:1406: warning: Function parameter or member 'new_exe_file' not described in 'set_mm_exe_file'
kernel/fork.c:1441: warning: Function parameter or member 'mm' not described in 'replace_mm_exe_file'
kernel/fork.c:1441: warning: Function parameter or member 'new_exe_file' not described in 'replace_mm_exe_file'
kernel/fork.c:1491: warning: Function parameter or member 'mm' not described in 'get_mm_exe_file'
kernel/fork.c:1510: warning: Function parameter or member 'task' not described in 'get_task_exe_file'
kernel/fork.c:1534: warning: Function parameter or member 'task' not described in 'get_task_mm'
kernel/fork.c:2109: warning: bad line:
kernel/fork.c:2130: warning: Function parameter or member 'ret' not described in '__pidfd_prepare'
kernel/fork.c:2130: warning: Excess function parameter 'pidfd' description in '__pidfd_prepare'
kernel/fork.c:2179: warning: Function parameter or member 'ret' not described in 'pidfd_prepare'
kernel/fork.c:2179: warning: Excess function parameter 'pidfd' description in 'pidfd_prepare'
kernel/fork.c:3195: warning: expecting prototype for clone3(). Prototype was for sys_clone3() instead
13 warnings as Errors
make[3]: *** [scripts/Makefile.build:243: kernel/fork.o] Error 13
make[3]: *** Deleting file 'kernel/fork.o'
make[2]: *** [scripts/Makefile.build:480: kernel] Error 2
make[1]: *** [/root/linux/Makefile:1913: .] Error 2
make: *** [Makefile:234: __sub-make] Error 2

>From the git history, commit 2c12c8103d ("scripts/kernel-doc:
optionally treat warnings as errors") introduces a new command-line
option to make kernel-doc warnings into errors. It can also read the
KCFLAGS environment variable to decide whether to turn this option on,
but the regex used for matching may not be accurate enough. It can match
both "-Werror" and "-Werror=<diagnostic-type>", so the option is turned
on by mistake in the latter case.

Fix this by strictly matching the flag "-Werror": there must be a space
or start of string in the front, and a space or end of string at the
end. This can handle all the following cases correctly:

KCFLAGS="-Werror" make W=1 [MATCH]
KCFLAGS="-Werror=return-type" make W=1 [NO MATCH]
KCFLAGS="-Wcomment -Werror -Wundef" make W=1 [MATCH]
KCFLAGS="-Wcomment -Werror=return-type -Wundef" make W=1 [NO MATCH]

Fixes: 2c12c8103d ("scripts/kernel-doc: optionally treat warnings as errors")
Signed-off-by: Yujie Liu <yujie.liu@intel.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <20231019095637.2471840-1-yujie.liu@intel.com>
2023-10-22 20:36:49 -06:00
..
atomic locking/atomic: scripts: fix ${atomic}_dec_if_positive() kerneldoc 2023-06-16 16:46:30 +02:00
basic kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion 2023-06-22 21:21:06 +09:00
clang-tools gen_compile_commands: add assembly files to compilation database 2023-07-23 22:36:07 +09:00
coccinelle Revert "debugfs, coccinelle: check for obsolete DEFINE_SIMPLE_ATTRIBUTE() usage" 2023-07-29 11:05:31 -04:00
dtc dt: dt-check-compatible: Find struct of_device_id instances with compiler annotations 2023-08-17 13:07:39 -05:00
dummy-tools kbuild: dummy-tools: make MPROFILE_KERNEL checks work on BE 2023-09-01 16:38:04 +09:00
gcc-plugins gcc-plugins: Rename last_stmt() for GCC 14+ 2023-08-10 23:10:09 -07:00
gdb scripts/gdb/vmalloc: add vmallocinfo support 2023-08-21 13:46:23 -07:00
genksyms
kconfig kconfig: fix possible buffer overflow 2023-09-06 02:00:02 +09:00
ksymoops
mod modpost: Skip .llvm.call-graph-profile section check 2023-09-01 15:58:17 +09:00
package kbuild: deb-pkg: support DEB_BUILD_OPTIONS=parallel=N in debian/rules 2023-08-29 22:29:35 +09:00
selinux
tracing tracing: Always use canonical ftrace path 2023-02-18 14:34:09 -05:00
.gitignore rust: support running Rust documentation tests as KUnit ones 2023-07-19 09:32:53 -06:00
as-version.sh kbuild: Update assembler calls to use proper flags and language target 2023-01-26 12:41:38 +09:00
asn1_compiler.c ASN.1: Fix check for strdup() success 2023-04-21 08:58:00 -07:00
bloat-o-meter scripts/bloat-o-meter: count weak symbol sizes 2023-08-21 13:46:25 -07:00
bootgraph.pl
bpf_doc.py bpf, docs: Fix invalid escape sequence warnings in bpf_doc.py 2023-08-31 13:56:31 +02:00
cc-can-link.sh
cc-version.sh scripts: Remove ICC-related dead code 2023-04-24 10:18:32 -07:00
check-git kbuild: use git-archive for source package creation 2023-03-16 22:46:12 +09:00
check-sysctl-docs sysctl: Remove register_sysctl_table 2023-05-23 21:43:26 -07:00
check_extable.sh
checkdeclares.pl
checkincludes.pl
checkkconfigsymbols.py scripts: handle BrokenPipeError for python scripts 2023-01-26 12:43:33 +09:00
checkpatch.pl - An extensive rework of kexec and crash Kconfig from Eric DeVolder 2023-08-29 14:53:51 -07:00
checkstack.pl sh: remove sh5/sh64 last fragments 2023-03-23 10:02:02 +01:00
checksyscalls.sh checksyscalls: ignore fstat to silence build warning on LoongArch 2023-03-23 17:18:32 -07:00
checkversion.pl
cleanfile
cleanpatch
coccicheck scripts: coccicheck: Use /usr/bin/env 2023-02-25 20:11:06 +01:00
config
const_structs.checkpatch const_structs.checkpatch.pl: add kobj_type 2023-02-08 13:33:29 +01:00
decode_stacktrace.sh
decodecode scripts/decodecode: Add support for RISC-V 2023-02-21 16:53:54 -08:00
depmod.sh kbuild: move depmod rule to scripts/Makefile.modinst 2023-08-29 22:38:23 +09:00
dev-needs.sh
diffconfig scripts: handle BrokenPipeError for python scripts 2023-01-26 12:43:33 +09:00
documentation-file-ref-check
export_report.pl
extract-ikconfig
extract-module-sig.pl
extract-sys-certs.pl
extract-vmlinux
extract_xc3028.pl
faddr2line
file-size.sh
find-unused-docs.sh
gcc-x86_32-has-stack-protector.sh
gcc-x86_64-has-stack-protector.sh
gen-randstruct-seed.sh
generate_initcall_order.pl
generate_rust_analyzer.py scripts: generate_rust_analyzer: provide cfgs for core and alloc 2023-08-20 22:54:32 +02:00
generate_rust_target.rs
get_abi.pl
get_dvb_firmware
get_feat.pl
get_maintainer.pl
gfp-translate scripts: fix the gfp flags header path in gfp-translate 2023-06-19 13:19:32 -07:00
head-object-list.txt powerpc/64: Rename entry_64.S to prom_entry_64.S 2023-06-15 14:04:19 +10:00
headerdep.pl
headers_install.sh x86: Remove the arch_calc_vm_prot_bits() macro from the UAPI 2023-09-06 23:50:46 +02:00
insert-sys-cert.c
install.sh
jobserver-exec scripts: support GNU make 4.4 in jobserver-exec 2023-01-16 20:15:20 +09:00
kallsyms.c scripts/kallsyms: Fix build failure by setting errno before calling getline() 2023-07-29 15:57:32 +09:00
Kbuild.include kbuild: replace $(dot-target).tmp in filechk with $(tmp-target) 2023-01-22 23:43:33 +09:00
Kconfig.include kbuild: Update assembler calls to use proper flags and language target 2023-01-26 12:41:38 +09:00
kernel-doc scripts/kernel-doc: match -Werror flag strictly 2023-10-22 20:36:49 -06:00
ld-version.sh
leaking_addresses.pl leaking_addresses: also skip canonical ftrace path 2023-03-29 06:52:08 -04:00
Lindent
link-vmlinux.sh Kbuild updates for v6.4 2023-04-30 11:32:53 -07:00
Makefile rust: support running Rust documentation tests as KUnit ones 2023-07-19 09:32:53 -06:00
Makefile.asm-generic
Makefile.build kbuild: rust: avoid creating temporary files 2023-07-24 03:15:31 +09:00
Makefile.clang Kbuild updates for v6.5 2023-07-01 09:24:31 -07:00
Makefile.clean kbuild: make clean rule robust against too long argument error 2023-06-25 23:12:20 +09:00
Makefile.compiler Kbuild updates for v6.5 2023-07-01 09:24:31 -07:00
Makefile.debug
Makefile.defconf kbuild: Provide a version of merge_into_defconfig without override warnings 2023-02-13 20:18:28 +01:00
Makefile.dtbinst kbuild: Support flat DTBs install 2023-06-21 07:51:08 -06:00
Makefile.extrawarn extrawarn: move -Wrestrict into W=1 warnings 2023-08-20 14:16:59 +09:00
Makefile.gcc-plugins
Makefile.headersinst
Makefile.host kbuild: rust: avoid creating temporary files 2023-07-24 03:15:31 +09:00
Makefile.kasan kasan: remove hwasan-kernel-mem-intrinsic-prefix=1 for clang-14 2023-04-18 16:29:43 -07:00
Makefile.kcov
Makefile.kcsan
Makefile.kmsan
Makefile.lib kbuild: Disallow DTB overlays to built from .dts named source files 2023-05-22 10:34:37 +09:00
Makefile.modfinal btf, scripts: rust: drop is_rust_module.sh 2023-08-10 22:28:04 +02:00
Makefile.modinst kbuild: support modules_sign for external modules as well 2023-09-01 15:58:17 +09:00
Makefile.modpost linux/export.h: make <linux/export.h> independent of CONFIG_MODULES 2023-07-25 00:59:32 +09:00
Makefile.package kbuild: deb-pkg: support DEB_BUILD_OPTIONS=parallel=N in debian/rules 2023-08-29 22:29:35 +09:00
Makefile.randstruct
Makefile.ubsan ubsan: Tighten UBSAN_BOUNDS on GCC 2023-05-16 13:57:14 -07:00
Makefile.userprogs
Makefile.vmlinux kbuild: Fix CFI failures with GCOV 2023-06-25 23:12:20 +09:00
Makefile.vmlinux_o
makelst
markup_oops.pl
min-tool-version.sh rust: bindgen: upgrade to 0.65.1 2023-08-15 00:37:22 +02:00
misc-check kbuild: make W=1 warn files that are tracked but ignored by git 2023-01-22 23:43:33 +09:00
mkcompile_h
mksysmap scripts/mksysmap: Ignore prefixed KCFI symbols 2023-06-27 08:35:43 +09:00
mkuboot.sh
module.lds.S
modules-check.sh
nsdeps
objdiff
objdump-func scripts/objdump-func: Support multiple functions 2023-04-14 16:08:28 +02:00
orc_hash.sh x86/unwind/orc: Add ELF section with ORC version identifier 2023-06-16 17:17:42 +02:00
pahole-flags.sh bpf: Add --skip_encoding_btf_inconsistent_proto, --btf_gen_optimized to pahole flags for v1.25 2023-05-12 11:47:05 -07:00
pahole-version.sh
parse-maintainers.pl
patch-kernel
profile2linkerlist.pl
prune-kernel
recordmcount.c recordmcount: Fix memory leaks in the uwrite function 2023-04-25 21:10:20 -04:00
recordmcount.h
recordmcount.pl
relocs_check.sh powerpc: Move script to check relocations at compile time in scripts/ 2023-04-19 07:46:31 -07:00
remove-stale-files kbuild: rpm-pkg: rename binkernel.spec to kernel.spec 2023-07-25 00:59:33 +09:00
rust_is_available.sh kbuild: rust_is_available: check that output looks as expected 2023-08-10 01:18:34 +02:00
rust_is_available_bindgen_libclang.h
rust_is_available_test.py kbuild: rust_is_available: add test suite 2023-08-10 01:18:34 +02:00
rustdoc_test_builder.rs rust: support running Rust documentation tests as KUnit ones 2023-07-19 09:32:53 -06:00
rustdoc_test_gen.rs rust: support running Rust documentation tests as KUnit ones 2023-07-19 09:32:53 -06:00
setlocalversion scripts/setlocalversion: also consider annotated tags of the form vx.y.z-${file_localversion} 2023-08-08 01:08:54 +09:00
show_delta
sign-file.c
sorttable.c
sorttable.h x86,objtool: Split UNWIND_HINT_EMPTY in two 2023-03-23 23:18:58 +01:00
spdxcheck-test.sh
spdxcheck.py
spdxexclude
spelling.txt scripts/spelling.txt: remove 'thead' as a typo 2023-07-27 13:07:04 -07:00
sphinx-pre-install
split-man.pl
stackdelta
stackusage
subarch.include
syscallhdr.sh
syscallnr.sh
syscalltbl.sh
tags.sh Char/Misc and other driver subsystem updates for 6.5-rc1 2023-07-03 12:46:47 -07:00
test_fortify.sh
tools-support-relr.sh Makefile: use -z pack-relative-relocs 2023-04-17 11:23:06 +09:00
unifdef.c
ver_linux
xen-hypercalls.sh
xz_wrap.sh