[Ltrace-devel] glob.c: In function 'globcomp': error: 'regex' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Sedat Dilek sedat.dilek at gmail.com
Thu Nov 8 19:55:14 UTC 2012


On Thu, Nov 8, 2012 at 8:32 PM, Petr Machata <pmachata at redhat.com> wrote:
> Sedat Dilek <sedat.dilek at gmail.com> writes:
>
>> Seen with ltrace-git up to commit
>> 4754ea02d067a88e87d4cc67500419f20781de39
>> ("4754ea02d067a88e87d4cc67500419f20781de39")
>> ...
>> 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./sysdeps/linux-gnu/mipsel -I./sysdeps/linux-gnu
>> -I./sysdeps -I. -DSYSCONFDIR=\"/etc\" -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 glob.lo -MD -MP -MF .deps/glob.Tpo -c
>> glob.c  -fPIC -DPIC -o .libs/glob.o
>> glob.c: In function 'globcomp':
>> glob.c:190:9: error: 'regex' may be used uninitialized in this
>> function [-Werror=maybe-uninitialized]
>> cc1: all warnings being treated as errors
>> make[3]: *** [glob.lo] Error 1
>> make[3]: Leaving directory
>> `/home/wearefam/src/freetz/freetz-git/source/target-mipsel_uClibc-0.9.33.2/ltrace-0.7.0-git'
>
> Again, this seem spurious.  Regex is initialized in glob_to_regex from
> buf, which is itself properly initialized.
>
> There's not even anything that I can reasonably initialize to.  Should I
> use NULL?  Then if it's not overwritten in glob_to_regex, this NULL gets
> passed to regcomp, and that SIGSEGVs.  So the full fix should look like:
>
> --- a/glob.c
> +++ b/glob.c
> @@ -183,9 +183,9 @@ glob_to_regex(const char *glob, char **retp)
>  int
>  globcomp(regex_t *preg, const char *glob, int cflags)
>  {
> -       char *regex;
> +       char *regex = NULL;
>         int status = glob_to_regex(glob, &regex);
> -       if (status != 0)
> +       if (status != 0 || regex == NULL)
>                 return status;
>         status = regcomp(preg, regex, cflags);
>         free(regex);
>

Jupp, that patch compiles fine.

> Frankly, that's just silly.  Please update your toolchain.  Let's deal
> with this (by filing bugs) if golden GCC complains as well.
>

Really not sure if updating toolchain will help as it is not only gcc involved.
The Freetz project has its own patchsets for diverse toolchain
components (binutils, gcc, uClibc, etc.).
But I can upgrade to gcc-4.7.2 - if this will be "golden" we will see :-).

- Sedat -

> Thanks,
> PM



More information about the Ltrace-devel mailing list