On (08/12/14 22:07), Jakub Hrozek wrote:
On Mon, Dec 08, 2014 at 10:35:15AM +0100, Lukas Slebodnik wrote:
> ehlo,
>
> Michal tried to fix gcc warning im commit
> cff89439b21f8573c6896b09cb1a8d5f9de3144c
>
> The previous fix was not sufficient and similar warning appears after different
> change in function load_configuration.
>
> src/monitor/monitor.c: In function ‘main’:
> src/monitor/monitor.c:2962:24: error: ‘monitor’ may be used uninitialized
> in this function [-Werror=maybe-uninitialized]
> monitor->is_daemon = !opt_interactive;
> ^
> cc1: all warnings being treated as errors
>
> It's better to disable optimisation of function load_configuration after fail
> in chown(unlink) instead of checking errno for 0 and overriding it with EINVAL.
>
> LS
I'm fine with the change and it gets rid of the ugly workaround. What OS
and what CFLAGS shall I use to test the fix?
It is possible to reproduce warning
with "-g -O2".
I can see it on fedora 21, rawhide.
fedora 20 and rhel7 has similar warning (I didn't tested with my patch)
src/monitor/monitor.c: In function 'main':
src/monitor/monitor.c:2263:9: warning: 'monitor' may be used uninitialized in this
function [-Wmaybe-uninitialized]
tes = tevent_add_signal(ctx->ev, ctx, SIGHUP, 0,
^
src/monitor/monitor.c:2772:20: note: 'monitor' was declared here
struct mt_ctx *monitor;
^
LS