linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Arnd Bergmann <arnd@arndb.de>" <arndb@onlinehome.de>
To: <arnd@arndb.de>
To: <akpm@osdl.org>
To: <linux-kernel@vger.kernel.org>
To: <eranian@hpl.hp.com>
To: <davidm@hpl.hp.com>
To: <juhl-lkml@dif.dk>
Subject: Re: [resend][PATCH] avoid signed vs unsigned comparison in efi_range_is_wc()
Date: Fri, 17 Jun 2005 02:25:59 +0200	[thread overview]
Message-ID: <13345630.1118967959638.JavaMail.servlet@kundenserver> (raw)

[-- Attachment #1: Type: text/plain, Size: 272 bytes --]

Jesper wrote:

>> Jesper, are you interested in my stuff
>
>Certainly.
>

Ok, here is the warning level patch for reference. I'm sending the rest of my stuff
to you off-list since it is rather largish and I don't have a working mail client
on this machine.

      Arnd <><

[-- Attachment #2: warn-levels.diff --]
[-- Type: application/octet-stream, Size: 5116 bytes --]

[PATCH] kbuild: selectable warning levels

This introduces four different levels of compiler warnings to the
kernel build environment. The idea is to enable developers to get the
extra static code checks that newer gcc versions provide without
annoying users with false positives.

I have tested this with gcc versions 2.95 through 4.0 on i386 as
well as some cross builds for x86_64, ppc64 and s390. The conditional
warning settings are needed to get some of the options that pre-4.0
compilers don't support.

I have not tested this at all with non-GNU compilers, so it
probably is not ready for inclusion in -mm at this point.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Index: linus-2.6/Makefile
===================================================================
--- linus-2.6.orig/Makefile	2005-06-17 00:57:11.000000000 +0200
+++ linus-2.6/Makefile	2005-06-17 01:54:36.000000000 +0200
@@ -348,8 +348,7 @@
 
 CPPFLAGS        := -D__KERNEL__ $(LINUXINCLUDE)
 
-CFLAGS 		:= -Wall -Wstrict-prototypes -Wno-trigraphs \
-	  	   -fno-strict-aliasing -fno-common \
+CFLAGS 		:= -fno-strict-aliasing -fno-common \
 		   -ffreestanding
 AFLAGS		:= -D__ASSEMBLY__
 
@@ -533,11 +532,46 @@
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 CHECKFLAGS     += $(NOSTDINC_FLAGS)
 
+# standard warnings
+CWARN_LESS         += -Wall -Wstrict-prototypes -Wno-trigraphs
 # warn about C99 declaration after statement
-CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
+CWARN_LESS         += $(call cc-option,-Wdeclaration-after-statement,)
+CWARN_LESS_COND    +=
+ifdef CONFIG_WARN_ERROR
+CWARN_LESS         += -Werror
+endif
+ifdef CONFIG_WARN_LESS
+CWARN_LESS         += -Wno-deprecated-declarations
+CWARN_LESS_COND    += -Wno-pointer-sign
+CFLAGS             += $(CWARN_LESS) $(call cc-option,$(CWARN_LESS_COND),)
+endif
+
+# warn about common problems
+CWARN_NORMAL       += $(CWARN_LESS) -Winline -Wcast-align -Wundef -Wformat
+CWARN_NORMAL       += -Wmissing-noreturn
+CWARN_NORMAL_COND  += $(CWARN_LESS_COND) -Wdisabled-optimization
+CWARN_NORMAL_COND  += -Wmissing-format-attribute -Wendif-labels
+ifdef CONFIG_WARN_NORMAL
+CWARN_NORMAL_COND  += -Wno-pointer-sign
+CFLAGS             += $(CWARN_NORMAL) $(call cc-option,$(CWARN_NORMAL_COND),)
+endif
 
-# disable pointer signedness warnings in gcc 4.0
-CFLAGS += $(call cc-option,-Wno-pointer-sign,)
+# these can get rather noisy
+CWARN_MORE         += $(CWARN_NORMAL) -Wredundant-decls -Wnested-externs
+CWARN_MORE         += -Wmissing-prototypes -Wwrite-strings -Wshadow
+CWARN_MORE_COND    += $(CWARN_NORMAL_COND)
+ifdef CONFIG_WARN_MORE
+CFLAGS             += $(CWARN_MORE) $(call cc-option,$(CWARN_MORE_COND),)
+endif
+
+# these usually don't do any good
+CWARN_TOOMUCH      += $(CWARN_MORE) -Waggregate-return -Wsign-compare
+CWARN_TOOMUCH      += -W -Wlarger-than-8192 -Wconversion -Wbad-function-cast
+CWARN_TOOMUCH      += -Wcast-qual
+CWARN_TOOMUCH_COND += $(CWARN_MORE_COND) -Wpadded -Wpacked -Wunreachable-code
+ifdef CONFIG_WARN_TOOMUCH
+CFLAGS             += $(CWARN_TOOMUCH) $(call cc-option,$(CWARN_TOOMUCH_COND),)
+endif
 
 # Default kernel image to build when no specific target is given.
 # KBUILD_IMAGE may be overruled on the commandline or
Index: linus-2.6/lib/Kconfig.debug
===================================================================
--- linus-2.6.orig/lib/Kconfig.debug	2005-06-17 00:57:11.000000000 +0200
+++ linus-2.6/lib/Kconfig.debug	2005-06-17 01:52:22.000000000 +0200
@@ -159,3 +159,49 @@
 	  If you don't debug the kernel, you can say N, but we may not be able
 	  to solve problems without frame pointers.
 
+choice
+	prompt "Compiler warning level"
+	default WARN_NORMAL
+	help
+	  Select how much the compiler should warn about kernel code.
+	  If unsure, select "Normal".
+
+config WARN_LESS
+	bool "Minimal"
+	help
+	  In minimal warning mode, only the traditional -Wall warnings are
+	  enabled, with the exception of deprecated interfaces. For common
+	  configurations, there ought to be no warnings at this level.
+	  Select this if you also want to built with -Werror.
+
+config WARN_NORMAL
+	bool "Normal"
+	help
+	  The normal warning level will warn about some common problems that
+	  may need to be fixed up. If you are maintaining code that is
+	  warned about at this level, you should try to fix that.
+
+config WARN_MORE
+	bool "More"
+	help
+	  Select "More" to enable some warnings that are rather noisy for
+	  existing parts of the kernel. This is most useful to check new code
+	  before it is submitted for inclusion.
+
+config WARN_TOOMUCH
+	bool "All"
+	help
+	  Enabling all warnings will create many warnings about good code that
+	  becomes less readable if you try to work around the warning. Patches
+	  to shut up warnings at this level are likely to be rejected unless
+	  they fix real problems.
+
+endchoice
+
+config WARN_ERROR
+	bool "Make all build warnings errors"
+	depends on WARN_LESS
+	help
+	  When this option is enabled, all compiler warnings are turned into
+	  errors, making it impossible to build the kernel while some warnings
+	  are left.

             reply	other threads:[~2005-06-17  0:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-17  0:25 Arnd Bergmann <arnd@arndb.de> [this message]
2005-06-17 17:04 ` [resend][PATCH] avoid signed vs unsigned comparison in efi_range_is_wc() Jesper Juhl
  -- strict thread matches above, loose matches on Subject: below --
2005-06-16 20:21 Jesper Juhl
2005-06-16 20:41 ` Andrew Morton
2005-06-16 21:02   ` Jesper Juhl
2005-06-16 21:48     ` Arnd Bergmann
2005-06-16 22:24       ` Jesper Juhl
2005-06-16 20:45 ` Richard B. Johnson
2005-06-16 21:07   ` Jesper Juhl
2005-06-16 21:32     ` Arnd Bergmann
2005-06-16 21:01 ` David Mosberger
2005-06-20 17:00   ` Jesse Barnes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13345630.1118967959638.JavaMail.servlet@kundenserver \
    --to=arndb@onlinehome.de \
    --cc=arnd@arndb.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).