From 9a53390dabcbee24e5ca48da56498ae8bb8060fd Mon Sep 17 00:00:00 2001 From: Chris Fries Date: Wed, 8 Mar 2017 08:08:38 -0600 Subject: [PATCH] kernel: Add CC_WERROR config to turn warnings into errors Add configuration option CONFIG_CC_WERROR to prevent warnings from creeping in. Signed-off-by: Chris Fries Signed-off-by: Nathan Chancellor Change-Id: I323b5c3ddee31278da0e6d18b278a2c1327ebd04 --- Makefile | 5 ++++- lib/Kconfig.debug | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index aaf11b2253ba..be4cba61d442 100644 --- a/Makefile +++ b/Makefile @@ -398,7 +398,6 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common \ -Werror-implicit-function-declaration \ -Wno-format-security -Wno-builtin-macro-redefined \ - -Werror \ -std=gnu89 $(call cc-option,-fno-PIE) # re-define of __func__, __file__ to save rodata size @@ -731,6 +730,10 @@ endif KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \ $(call cc-disable-warning,maybe-uninitialized,)) +ifdef CONFIG_CC_WERROR +KBUILD_CFLAGS += -Werror +endif + # Tell gcc to never replace conditional load with a non-conditional one KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 89bf8889b773..263ae5f96301 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1985,6 +1985,16 @@ config TEST_STATIC_KEYS If unsure, say N. +config CC_WERROR + bool "Treat all compile warnings as errors" + default n + help + Select this option to set compiler warnings as errors, + to prevent easily-fixable problems from creeping into + the codebase. + + If unsure, say N. + source "samples/Kconfig" source "lib/Kconfig.kgdb"