]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 439685 compiler warning in callgrind/main.c
authorMark Wielaard <mark@klomp.org>
Wed, 19 Apr 2023 22:42:40 +0000 (00:42 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 19 Apr 2023 22:49:28 +0000 (00:49 +0200)
main.c: In function 'vgCallgrind_post_syscalltime':
main.c:1779:25: warning: '*((void *)&ts_now+8)'
    may be used uninitialized in this function [-Wmaybe-uninitialized]
     struct vki_timespec ts_now;
main.c:1779:25: warning: 'ts_now'
    may be used uninitialized in this function [-Wmaybe-uninitialized]

In function collect_time the conditional expression in the switch
statement has type int (after integral promotions). GCC assumes that
it may have values other than the ones listed in the enumerated type
it was promoted from.  In that case the memory pointed to by its 1st
argument remains unintialised.  Later on vki_timespec_diff will read
the contents of ts_now undoditionally.  Hence the warning.

Using the default case for the tl_assert () removes the warning and
makes the code more robust should another enumerator ever be added to
Collect_Systime.

Contributed-by: Florian Krohm <florian@eich-krohm.de>
NEWS
callgrind/main.c

diff --git a/NEWS b/NEWS
index 1b9bdb869ddaf266964a3ce1f0ace11b9f173d10..a8fed85bf45eb35320331edfeabcf36f59ac968b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -131,6 +131,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 433873  openat2 syscall unimplemented on Linux
 434057  Add stdio mode to valgrind's gdbserver
 435441  valgrind fails to interpose malloc on musl 1.2.2 due to weak symbol name and no libc soname
+439685  compiler warning in callgrind/main.c
 444110  priv/guest_ppc_toIR.c:36198:31: warning: duplicated 'if' condition.
 444488  Use glibc.pthread.stack_cache_size tunable
 444568  drd/tests/pth_barrier_thr_cr fails on Fedora 38
index 4970d5a4d7a5ce4b3487cfdf9ddef71bd9d0ce91..0c2467a90fb1c05677eb74c23d80a1cc793bcc7b 100644 (file)
@@ -1711,7 +1711,7 @@ static
 void collect_time (struct vki_timespec *systime, struct vki_timespec *syscputime)
 {
   switch (CLG_(clo).collect_systime) {
-    case systime_no: tl_assert (0);
+    default: tl_assert (0);
     case systime_msec: {
       UInt ms_timer = VG_(read_millisecond_timer)();
       systime->tv_sec = ms_timer / 1000;