Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1386597 > unrolled thread

[RESEND PATCH 0/5] gcov fixes and maybe-uninitialized warnings

Started byArnd Bergmann <arnd@arndb.de>
First post2016-04-25 17:40 +0200
Last post2016-04-25 17:40 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [RESEND PATCH 0/5] gcov fixes and maybe-uninitialized warnings Arnd Bergmann <arnd@arndb.de> - 2016-04-25 17:40 +0200
    [PATCH 2/5] Kbuild: disable 'maybe-uninitialized' warning for CONFIG_PROFILE_ALL_BRANCHES Arnd Bergmann <arnd@arndb.de> - 2016-04-25 17:40 +0200

#1386597 — [RESEND PATCH 0/5] gcov fixes and maybe-uninitialized warnings

FromArnd Bergmann <arnd@arndb.de>
Date2016-04-25 17:40 +0200
Subject[RESEND PATCH 0/5] gcov fixes and maybe-uninitialized warnings
Message-ID<rrQM9-8el-3@gated-at.bofh.it>
Hi Michal,

This is a resend of a series I originally sent back in February, but
unfortunately I never heard back from you. Could you apply these
patches for v4.7?

[PATCH 1/5] Kbuild: change CC_OPTIMIZE_FOR_SIZE definition
[PATCH 2/5] Kbuild: disable 'maybe-uninitialized' warning for
[PATCH 3/5] gcov: disable for COMPILE_TEST
[PATCH 4/5] gcov: disable tree-loop-im to reduce stack usage
[PATCH 5/5] gcov: disable -Wmaybe-uninitialized warning

I've marked patch 4/5 for stable backports, please decide for
yourself if you want to send it for v4.6 right away, it's
not overly urgent but it does fix real bugs unlike the others
that just address the warning levels.

	Arnd
----
Original description:

This series tries to address two related problems:

* getting better "variable may be used uninitialized" warnings
  in allmodconfig and randconfig builds

* improving GCOV_PROFILE support

Surprisingly, these two are related, so I have a single series that
I hope to get merged through the Kbuild tree.

I have built many thousands of ARM randconfig kernels and created
patches for every single warning and error I found, and submitted
most of them for inclusion. The "may be used uninitialized" warnings
are both the most annoying and the most helpful ones that gcc
gives us, so this tries to make them more useful, including three
steps:

1. Limit the false positives as much as we can: Aside from
   CC_OPTIMIZE_FOR_SIZE, three other options (UBSAN_SANITIZE_ALL,
   PROFILE_ALL_BRANCHES and GCOV_PROFILE_ALL) confuse the
   compiler (in versions 4.9 through 5.3, and to a lesser degree
   on older versions) so we get a lot of extra warnings. We
   already disable the warnings for CC_OPTIMIZE_FOR_SIZE, and
   this series also disables them for the other two, which are
   rarely used in practice but do show up in randconfig builds
   all the time.
2. Ensure we actually see them on 'allmodconfig' builds: Today they
   are disabled, because CC_OPTIMIZE_FOR_SIZE disables them.
   UBSAN_SANITIZE_ALL and PROFILE_ALL_BRANCHES are defined in
   a way that they don't get turned on for allmodconfig, and
   we need to do the samem for GCOV_PROFILE_ALL and
   CC_OPTIMIZE_FOR_SIZE.
3. Fix all known such warnings: The warnings should stick out,
   so we can fix them once they first appear. Today they often
   get ignored because of all the false positives.

For GCOV support, another problem showed up, resulting in an increased
risk for kernel stack overflow, aside from getting a number of
warnings about the stack size. I'm also including a patch to
address that here.

[toc] | [next] | [standalone]


#1386598 — [PATCH 2/5] Kbuild: disable 'maybe-uninitialized' warning for CONFIG_PROFILE_ALL_BRANCHES

FromArnd Bergmann <arnd@arndb.de>
Date2016-04-25 17:40 +0200
Subject[PATCH 2/5] Kbuild: disable 'maybe-uninitialized' warning for CONFIG_PROFILE_ALL_BRANCHES
Message-ID<rrQMb-8el-31@gated-at.bofh.it>
In reply to#1386597
CONFIG_PROFILE_ALL_BRANCHES confuses gcc-5.x to the degree that it prints
incorrect warnings about a lot of variables that it thinks can be used
uninitialized, e.g.:

i2c/busses/i2c-diolan-u2c.c: In function 'diolan_usb_xfer':
i2c/busses/i2c-diolan-u2c.c:391:16: warning: 'byte' may be used uninitialized in this function
iio/gyro/itg3200_core.c: In function 'itg3200_probe':
iio/gyro/itg3200_core.c:213:6: warning: 'val' may be used uninitialized in this function
leds/leds-lp55xx-common.c: In function 'lp55xx_update_bits':
leds/leds-lp55xx-common.c:350:6: warning: 'tmp' may be used uninitialized in this function
misc/bmp085.c: In function 'show_pressure':
misc/bmp085.c:363:10: warning: 'pressure' may be used uninitialized in this function
power/ds2782_battery.c: In function 'ds2786_get_capacity':
power/ds2782_battery.c:214:17: warning: 'raw' may be used uninitialized in this function

These are all false positives that either rob someone's time when trying
to figure out whether they are real, or they get people to send wrong
patches to shut up the warnings.

Nobody normally wants to run a CONFIG_PROFILE_ALL_BRANCHES kernel in
production, so disabling the whole class of warnings for this configuration
has no serious downsides either.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Steven Rostedt <rostedtgoodmis.org>
---
 Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index c5a3db5aebd1..e595d1f626b8 100644
--- a/Makefile
+++ b/Makefile
@@ -624,7 +624,11 @@ KBUILD_CFLAGS	+= $(call cc-option,-fno-delete-null-pointer-checks,)
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS	+= -Os $(call cc-disable-warning,maybe-uninitialized,)
 else
-KBUILD_CFLAGS	+= -O2
+ifdef CONFIG_PROFILE_ALL_BRANCHES
+KBUILD_CFLAGS	+= -O2 $(call cc-disable-warning,maybe-uninitialized,)
+else
+KBUILD_CFLAGS   += -O2
+endif
 endif
 
 # Tell gcc to never replace conditional load with a non-conditional one
-- 
2.7.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web