Re: [PATCH 1/2] kbuild: refactor scripts/Makefile.extrawarn

From: Sedat Dilek
Date: Wed Aug 28 2019 - 12:00:14 EST


Something like that...

[PATCH 1/2] kbuild: Improve extrawarn documentation
[PATCH 2/2] kbuild: Rename extrawarn Kconfig to KBUILD_EXTRA_CC_CHECKS

- Sedat -
From 1275ec0f1d31c4ac57b73b318bdc45151d99e8dc Mon Sep 17 00:00:00 2001
From: Sedat Dilek <sedat.dilek@xxxxxxxxxxx>
Date: Wed, 28 Aug 2019 16:27:13 +0200
Subject: [PATCH 1/2] kbuild: Improve extrawarn documentation

---
Documentation/kbuild/kbuild.rst | 10 ++++++++--
scripts/Makefile.extrawarn | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst
index 62f9d86c082c..f0f1c475d7fa 100644
--- a/Documentation/kbuild/kbuild.rst
+++ b/Documentation/kbuild/kbuild.rst
@@ -243,8 +243,14 @@ To get all available archs you can also specify all. E.g.::

KBUILD_ENABLE_EXTRA_GCC_CHECKS
------------------------------
-If enabled over the make command line with "W=1", it turns on additional
-gcc -W... options for more extensive build-time checking.
+If enabled over the make command line with "W=...", it turns on additional
+compiler warning options like -Wmissing-declarations for more extensive
+build-time checking. For more details see <scripts/Makefile.extrawarn>.
+
+W=1 - warnings that may be relevant and does not occur too often
+W=1 - also stops suppressing some warnings
+W=2 - warnings that occur quite often but may still be relevant
+W=3 - the more obscure warnings, can most likely be ignored

KBUILD_BUILD_TIMESTAMP
----------------------
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 3af1770497fd..6770f8da4e6d 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -32,7 +32,7 @@ KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1

else

-# W=1 also stops suppressing some warnings
+# W=1 - also stops suppressing some warnings

ifdef CONFIG_CC_IS_CLANG
KBUILD_CFLAGS += -Wno-initializer-overrides
--
2.20.1

From b364881f8b2a7aa258dcdbaba8d6bc57b41def0d Mon Sep 17 00:00:00 2001
From: Sedat Dilek <sedat.dilek@xxxxxxxxxxx>
Date: Wed, 28 Aug 2019 16:30:03 +0200
Subject: [PATCH 2/2] kbuild: Rename extrawarn Kconfig to
KBUILD_EXTRA_CC_CHECKS

---
Documentation/kbuild/kbuild.rst | 2 +-
scripts/Makefile.build | 2 +-
scripts/Makefile.extrawarn | 8 ++++----
scripts/Makefile.lib | 4 ++--
scripts/genksyms/Makefile | 2 +-
5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst
index f0f1c475d7fa..dcc83d993459 100644
--- a/Documentation/kbuild/kbuild.rst
+++ b/Documentation/kbuild/kbuild.rst
@@ -241,7 +241,7 @@ To get all available archs you can also specify all. E.g.::

$ make ALLSOURCE_ARCHS=all tags

-KBUILD_ENABLE_EXTRA_GCC_CHECKS
+KBUILD_EXTRA_CC_CHECKS
------------------------------
If enabled over the make command line with "W=...", it turns on additional
compiler warning options like -Wmissing-declarations for more extensive
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 2a21ca86b720..1de9b9ddddaa 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -85,7 +85,7 @@ else ifeq ($(KBUILD_CHECKSRC),2)
cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $<
endif

-ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
+ifneq ($(KBUILD_EXTRA_CC_CHECKS),)
cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $<
endif

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 6770f8da4e6d..0ee4a5a88d2c 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -6,13 +6,13 @@
KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)

ifeq ("$(origin W)", "command line")
- export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
+ export KBUILD_EXTRA_CC_CHECKS := $(W)
endif

#
# W=1 - warnings that may be relevant and does not occur too often
#
-ifneq ($(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+ifneq ($(findstring 1, $(KBUILD_EXTRA_CC_CHECKS)),)

KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
KBUILD_CFLAGS += -Wmissing-declarations
@@ -46,7 +46,7 @@ endif
#
# W=2 - warnings that occur quite often but may still be relevant
#
-ifneq ($(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+ifneq ($(findstring 2, $(KBUILD_EXTRA_CC_CHECKS)),)

KBUILD_CFLAGS += -Wcast-align
KBUILD_CFLAGS += -Wdisabled-optimization
@@ -65,7 +65,7 @@ endif
#
# W=3 - the more obscure warnings, can most likely be ignored
#
-ifneq ($(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+ifneq ($(findstring 3, $(KBUILD_EXTRA_CC_CHECKS)),)

KBUILD_CFLAGS += -Wbad-function-cast
KBUILD_CFLAGS += -Wcast-qual
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 888e5c830646..1f9e38550ce4 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -248,7 +248,7 @@ quiet_cmd_gzip = GZIP $@
DTC ?= $(objtree)/scripts/dtc/dtc

# Disable noisy checks by default
-ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+ifeq ($(findstring 1,$(KBUILD_EXTRA_CC_CHECKS)),)
DTC_FLAGS += -Wno-unit_address_vs_reg \
-Wno-unit_address_format \
-Wno-avoid_unnecessary_addr_size \
@@ -259,7 +259,7 @@ DTC_FLAGS += -Wno-unit_address_vs_reg \
-Wno-pci_device_reg
endif

-ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+ifneq ($(findstring 2,$(KBUILD_EXTRA_CC_CHECKS)),)
DTC_FLAGS += -Wnode_name_chars_strict \
-Wproperty_name_chars_strict
endif
diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
index baf44ed0a93a..e08fc3a6f7e2 100644
--- a/scripts/genksyms/Makefile
+++ b/scripts/genksyms/Makefile
@@ -12,7 +12,7 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o
#
# Just in case, run "$(YACC) --version" without suppressing stderr
# so that 'bison: not found' will be displayed if it is missing.
-ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+ifeq ($(findstring 1,$(KBUILD_EXTRA_CC_CHECKS)),)

quiet_cmd_bison_no_warn = $(quiet_cmd_bison)
cmd_bison_no_warn = $(YACC) --version >/dev/null; \
--
2.20.1