[Ltrace-devel] ERROR: 'entry.a_un.a_val' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Sedat Dilek sedat.dilek at gmail.com
Thu Nov 8 14:42:46 UTC 2012


On Fri, Nov 2, 2012 at 5:45 PM, Sedat Dilek <sedat.dilek at gmail.com> wrote:
> From my build-log...
> [...]
> /bin/bash ../../libtool --tag=CC   --mode=compile
> /home/wearefam/src/freetz/freetz-git/toolchain/build/mipsel_gcc-4.7.2-RC-20120914_uClibc-0.9.33.2/mipsel-linux-uclibc/bin/mipsel-linux-uclibc-gcc
> -DHAVE_CONFIG_H -I. -I../..  -I../../sysdeps/linux-gnu/mipsel
> -I../../sysdeps/linux-gnu       -I../../sysdeps         -I../..
> -Wall -Wsign-compare -Wfloat-equal -Wformat-security -Werror
> -march=4kc -Os -pipe -Wa,--trap -D_LARGEFILE_SOURCE
> -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -MT proc.lo -MD -MP -MF
> .deps/proc.Tpo -c -o proc.lo proc.c
> libtool: compile:
> /home/wearefam/src/freetz/freetz-git/toolchain/build/mipsel_gcc-4.7.2-RC-20120914_uClibc-0.9.33.2/mipsel-linux-uclibc/bin/mipsel-linux-uclibc-gcc
> -DHAVE_CONFIG_H -I. -I../.. -I../../sysdeps/linux-gnu/mipsel
> -I../../sysdeps/linux-gnu -I../../sysdeps -I../.. -Wall -Wsign-compare
> -Wfloat-equal -Wformat-security -Werror -march=4kc -Os -pipe
> -Wa,--trap -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
> -D_FILE_OFFSET_BITS=64 -MT proc.lo -MD -MP -MF .deps/proc.Tpo -c
> proc.c  -fPIC -DPIC -o .libs/proc.o
> proc.c: In function 'process_get_entry':
> proc.c:674:28: error: 'entry.a_un.a_val' may be used uninitialized in
> this function [-Werror=maybe-uninitialized]
> cc1: all warnings being treated as errors
> make[5]: *** [proc.lo] Error 1
> make[5]: Leaving directory
> `/home/wearefam/src/freetz/freetz-git/source/target-mipsel_uClibc-0.9.33.2/ltrace-0.7.0-git5511311/sysdeps/linux-gnu'
> make[4]: *** [all-recursive] Error 1
> make[4]: Leaving directory
> `/home/wearefam/src/freetz/freetz-git/source/target-mipsel_uClibc-0.9.33.2/ltrace-0.7.0-git5511311/sysdeps/linux-gnu'
> make[3]: *** [all-recursive] Error 1
> make[3]: Leaving directory
> `/home/wearefam/src/freetz/freetz-git/source/target-mipsel_uClibc-0.9.33.2/ltrace-0.7.0-git5511311/sysdeps'
> make[2]: *** [all-recursive] Error 1
> make[2]: Leaving directory
> `/home/wearefam/src/freetz/freetz-git/source/target-mipsel_uClibc-0.9.33.2/ltrace-0.7.0-git5511311'
> make[1]: *** [all] Error 2
> make[1]: Leaving directory
> `/home/wearefam/src/freetz/freetz-git/source/target-mipsel_uClibc-0.9.33.2/ltrace-0.7.0-git5511311'
>
> ERROR: Build failed.
> make: *** [source/target-mipsel_uClibc-0.9.33.2/ltrace-0.7.0-git5511311/ltrace]
> Error 1
>
> Lazy as I am I workaround-ed (see attached patch) :-).
>
> Excerpts from "ltrace-0.7.0-git5511311/sysdeps/linux-gnu/proc.c":
> ...
> int
> process_get_entry(struct Process *proc,
>                   arch_addr_t *entryp,
>                   arch_addr_t *interp_biasp)
> {
>         PROC_PID_FILE(fn, "/proc/%d/auxv", proc->pid);
>         int fd = open(fn, O_RDONLY);
>         if (fd == -1) {
>         fail:
>                 fprintf(stderr, "couldn't read %s: %s", fn, strerror(errno));
>         done:
>                 if (fd != -1)
>                         close(fd);
>                 return fd == -1 ? -1 : 0;
>         }
>
>         arch_addr_t at_entry = 0;
>         arch_addr_t at_bias = 0;
>        /*** Initialize here??? ***/
>         while (1) {
>                 Elf64_auxv_t entry;
>                 if (auxv_fetcher(proc)(fd, &entry) < 0)
>                         goto fail;
>
>                 switch (entry.a_type) {
>                 case AT_BASE:
>                         /* XXX The double cast should be removed when
>                          * arch_addr_t becomes integral type.  */
>                         at_bias = (arch_addr_t)(uintptr_t)entry.a_un.a_val;
>                         continue;
>
>                 case AT_ENTRY:
>                         /* XXX The double cast should be removed when
>                          * arch_addr_t becomes integral type.  */
>                         at_entry = (arch_addr_t)(uintptr_t)entry.a_un.a_val;
>                 default:
>                         continue;
>
>                 case AT_NULL:
>                         break;
>                 }
>                 break;
>         }
>
>         if (entryp != NULL)
>                 *entryp = at_entry;
>         if (interp_biasp != NULL)
>                 *interp_biasp = at_bias;
>         goto done;
> }
> ...
>
> - Sedat -

Anyone has a fix for this issue?
With modern gcc-versions (here I use gcc-4.7.2-RC) this warning is
treated as an error (see also gcc-manual chapter "3.8 Options to
Request or Suppress Warnings" [1]).
I still need to suppress the warning for a successfull build on MIPSEL.

[ make/ltrace/ltrace.mk ]
..
TARGET_CC_OPTS := -Wno-error=maybe-uninitialized
...
                CFLAGS="$(TARGET_CFLAGS) $(TARGET_CC_OPTS)" \
...

Not sure how to fix it by myself (see above excerpt with my notes).
It would be great to fix this before tomorrow's ltrace v0.7.0 FINAL.
Thanks in advance.

- Sedat -

[1] http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options



More information about the Ltrace-devel mailing list