diff options
author | Yujie Liu <yujie.liu@intel.com> | 2023-10-30 16:54:04 +0800 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2023-10-30 10:52:07 -0600 |
commit | cf63348b4c45384d02126f86676d5afc75d661a7 (patch) | |
tree | 137b990ef4688d0ad75afce31e0f37fe343a664e /scripts/kernel-doc | |
parent | e7abea958b7f0d65baafb20af60bdf2073fb2b28 (diff) |
scripts/kernel-doc: Fix the regex for matching -Werror flag
Swarup reported a "make htmldocs" warning:
Variable length lookbehind is experimental in regex;
marked by <-- HERE in m/(?<=^|\s)-Werror(?=$|\s)
<-- HERE / at ./scripts/kernel-doc line 188.
Akira managed to reproduce it by perl v5.34.0.
On second thought, it is not necessary to have the complicated
"lookahead and lookbehind" things, and the regex can be simplified.
Generally, the kernel-doc warnings should be considered as errors only
when "-Werror" flag is set in KCFLAGS, but not when
"-Werror=<diagnostic-type>" is set, which means there needs to be a
space or start of string before "-Werror", and a space or end of string
after "-Werror".
The following cases have been tested to work as expected:
* kernel-doc warnings are considered as errors:
$ KCFLAGS="-Werror" make W=1
$ KCFLAGS="-Wcomment -Werror" make W=1
$ KCFLAGS="-Werror -Wundef" make W=1
$ KCFLAGS="-Wcomment -Werror -Wundef" make W=1
* kernel-doc warnings remain as warnings:
$ KCFLAGS="-Werror=return-type" make W=1
$ KCFLAGS="-Wcomment -Werror=return-type" make W=1
$ KCFLAGS="-Werror=return-type -Wundef" make W=1
$ KCFLAGS="-Wcomment -Werror=return-type -Wundef" make W=1
The "Variable length lookbehind is experimental in regex" warning is
also resolved by this patch.
Fixes: 91f950e8b9d8 ("scripts/kernel-doc: match -Werror flag strictly")
Reported-by: Swarup Laxman Kotiaklapudi <swarupkotikalapudi@gmail.com>
Signed-off-by: Yujie Liu <yujie.liu@intel.com>
Closes: https://lore.kernel.org/r/20231028182231.123996-1-swarupkotikalapudi@gmail.com/
Reviewed-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20231030085404.3343403-1-yujie.liu@intel.com
Diffstat (limited to 'scripts/kernel-doc')
-rwxr-xr-x | scripts/kernel-doc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index d660e1f4b483..08a3e603db19 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -185,7 +185,7 @@ if (defined($ENV{'KBUILD_VERBOSE'}) && $ENV{'KBUILD_VERBOSE'} =~ '1') { if (defined($ENV{'KCFLAGS'})) { my $kcflags = "$ENV{'KCFLAGS'}"; - if ($kcflags =~ /(?<=^|\s)-Werror(?=$|\s)/) { + if ($kcflags =~ /(\s|^)-Werror(\s|$)/) { $Werror = 1; } } |