From d57b56474555199818e8e4a7803a0654887c2dc5 Mon Sep 17 00:00:00 2001 From: Chenglu Lin Date: Mon, 23 Sep 2019 13:15:50 +0800 Subject: [PATCH] kernel: Add CC_WERROR config to turn warnings into errors Add configuration option CONFIG_CC_WERROR to prevent warnings from creeping in. Bug: 141372918 Change-Id: Ie2d067c0177d8f13e9aaa9a78867998e390f89ee Signed-off-by: Chenglu Lin --- Makefile | 4 ++++ lib/Kconfig.debug | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/Makefile b/Makefile index ac4169832c64..ffa6e8396a75 100644 --- a/Makefile +++ b/Makefile @@ -764,6 +764,10 @@ else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += -Os endif +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) KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 6b3f1088f8a5..b74832919af2 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2172,6 +2172,16 @@ config PANIC_ON_DATA_CORRUPTION If we do not panic immediately after corruptions have been detected, the problem context is lost in the ensuing system mayhem. +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"