Advertisement
Guest User

Untitled

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