Commit bed4ed30 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Jonathan Corbet

scripts/kernel-doc: Override -Werror from KCFLAGS with KDOC_WERROR

Since commit 2c12c810 ("scripts/kernel-doc: optionally treat
warnings as errors"), the kernel-doc script will treat warnings as
errors when one of the following conditions is true:

- The KDOC_WERROR environment variable is non-zero
- The KCFLAGS environment variable contains -Werror
- The -Werror parameter is passed to kernel-doc

Checking KCFLAGS for -Werror allows piggy-backing on the C compiler
error handling. However, unlike the C compiler, kernel-doc has no
provision for -Wno-error. This makes compiling the kernel with -Werror
(to catch regressions) and W=1 (to enable more checks) always fail,
without the same possibility as offered by the C compiler to treating
some selected warnings as warnings despite the global -Werror setting.

To fix this, evaluate KDOC_WERROR after KCFLAGS, which allows disabling
the warnings-as-errors behaviour of kernel-doc selectively by setting
KDOC_WERROR=0.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20210730225401.4401-1-laurent.pinchart+renesas@ideasonboard.comSigned-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 4f3791c3
...@@ -329,10 +329,6 @@ if (defined($ENV{'KBUILD_VERBOSE'})) { ...@@ -329,10 +329,6 @@ if (defined($ENV{'KBUILD_VERBOSE'})) {
$verbose = "$ENV{'KBUILD_VERBOSE'}"; $verbose = "$ENV{'KBUILD_VERBOSE'}";
} }
if (defined($ENV{'KDOC_WERROR'})) {
$Werror = "$ENV{'KDOC_WERROR'}";
}
if (defined($ENV{'KCFLAGS'})) { if (defined($ENV{'KCFLAGS'})) {
my $kcflags = "$ENV{'KCFLAGS'}"; my $kcflags = "$ENV{'KCFLAGS'}";
...@@ -341,6 +337,10 @@ if (defined($ENV{'KCFLAGS'})) { ...@@ -341,6 +337,10 @@ if (defined($ENV{'KCFLAGS'})) {
} }
} }
if (defined($ENV{'KDOC_WERROR'})) {
$Werror = "$ENV{'KDOC_WERROR'}";
}
# Generated docbook code is inserted in a template at a point where # Generated docbook code is inserted in a template at a point where
# docbook v3.1 requires a non-zero sequence of RefEntry's; see: # docbook v3.1 requires a non-zero sequence of RefEntry's; see:
# https://www.oasis-open.org/docbook/documentation/reference/html/refentry.html # https://www.oasis-open.org/docbook/documentation/reference/html/refentry.html
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment