Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commit 742a85ef574eed16d5d89f454f0eb5a5863ff665
- Author: Arnd Bergmann <arnd@arndb.de>
- Date: Sun Sep 10 15:24:40 2017 +0200
- [RFC] Kconfig: disable -Wuninitialized for old compilers
- gcc-4.8 has a lot of false positive warnings with -Wmaybe-uninitialized,
- and we disable those already. However, older compilers have even more
- such false-positive warnings, which clutter the build logs and are not
- disabled because they don't understand the -Wno-maybe-uninitialized
- flag.
- This turns them off as well by disabling -Wuninitialized entirely
- by default (unless 'make W=1' is used), significantly reducing the
- total number of warnings, e.g. on current linux-next:
- before after
- defconfig allmodconfig defconfig allmodconfig
- gcc-4.3 45 364 0 74
- gcc-4.4 68 210 0 4
- gcc-4.5 33 145 0 6
- gcc-4.6 8 39 0 3
- gcc-4.7 0 12 0 3
- I have also submitted patches for the remaining warnings we get on
- gcc-4.6+, so we should get a clean build at least for allmodconfig with
- this patch. I have also looked at all 39 warnings we get with gcc-4.6 on
- an allmodconfig build. 35 of them are false-positives that newer gccs
- correctly understand and don't warn about. The remaining foud are also
- false-positives, but I would expect gcc to warn about them anyway since
- it cannot see why the code is safe:
- drivers/media/platform/rcar_drif.c:658:2: error: ‘ret’ may be used uninitialized in this function [-Werror=uninitialized]
- drivers/mtd/spi-nor/stm32-quadspi.c:248:2: error: ‘ret’ may be used uninitialized in this function [-Werror=uninitialized]
- drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c:147:6: error: ‘err’ may be used uninitialized in this function [-Werror=uninitialized]
- drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.c:126:6: error: ‘err’ may be used uninitialized in this function [-Werror=uninitialized]
- All four cases are for code that initializes a return code in a loop
- that may be entered at all for invalid arguments (typically a counter).
- Newer gcc and clang transform this so the return code of the function
- becomes zero unless one loop iteration has failed earlier. The variable
- holding the return code is optimized away before those warnings get
- generated. In practice, those functions should never be called with a
- zero loop counter, but I decided to submit patches for them anyway.
- Presumably, smatch also detects all four as uninitialized variable uses,
- but I did not try that.
- Cc: Geert Uytterhoeven <geert@linux-m68k.org>
- Cc: Dan Carpenter <dan.carpenter@oracle.com>
- Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82203
- Signed-off-by: Arnd Bergmann <arnd@arndb.de>
- ---
- Geert, you probably have an opinion on this, as you do build-testing
- with gcc-4.1 and regularly report new warnings you get. I think
- overall, we are better off without the false-positives here, and
- we still get the regular warnings from newer compilers.
- Would this patch get in your way?
- diff --git a/Makefile b/Makefile
- index 467042f98be5..d1c7933fab76 100644
- --- a/Makefile
- +++ b/Makefile
- @@ -633,7 +633,10 @@ KBUILD_CFLAGS += -O2
- endif
- endif
- -KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
- +KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0408, \
- + $(call cc-disable-warning,uninitialized,))
- +
- +KBUILD_CFLAGS += $(call cc-ifversion, -eq, 0408, \
- $(call cc-disable-warning,maybe-uninitialized,))
- # Tell gcc to never replace conditional load with a non-conditional one
- diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
- index 4fac8fe024b7..7b9003515fa6 100644
- --- a/scripts/Makefile.extrawarn
- +++ b/scripts/Makefile.extrawarn
- @@ -28,6 +28,7 @@ warning-1 += $(call cc-option, -Wunused-but-set-variable)
- warning-1 += $(call cc-option, -Wunused-const-variable)
- warning-1 += $(call cc-disable-warning, missing-field-initializers)
- warning-1 += $(call cc-disable-warning, sign-compare)
- +warning-1 += -Wuninitialized
- warning-2 := -Waggregate-return
- warning-2 += -Wcast-align
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement