[systemd-devel] [PATCH] Fix a few compiler warnings

Djalal Harouni tixxdz at opendz.org
Mon May 19 18:00:47 PDT 2014


On Mon, May 19, 2014 at 07:52:20PM +0200, Tom Gundersen wrote:
> On Sun, May 18, 2014 at 10:30 PM, Cristian Rodríguez
> <crrodriguez at opensuse.org> wrote:
> > ---
> >  src/journal/test-journal-stream.c  | 2 +-
> >  src/libsystemd/sd-login/sd-login.c | 2 +-
> >  src/shared/util.c                  | 4 ++--
> >  3 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c
> > index 8e1d08d..4f56edb 100644
> > --- a/src/journal/test-journal-stream.c
> > +++ b/src/journal/test-journal-stream.c
> > @@ -41,7 +41,7 @@ static void verify_contents(sd_journal *j, unsigned skip) {
> >                  const void *d;
> >                  char *k, *c;
> >                  size_t l;
> > -                unsigned u;
> > +                unsigned u = 0;
> >
> >                  assert_se(sd_journal_get_cursor(j, &k) >= 0);
> >                  printf("cursor: %s\n", k);
> > diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c
> > index e7eea19..583095d 100644
> > --- a/src/libsystemd/sd-login/sd-login.c
> > +++ b/src/libsystemd/sd-login/sd-login.c
> > @@ -82,7 +82,7 @@ _public_ int sd_pid_get_owner_uid(pid_t pid, uid_t *uid) {
> >  }
> >
> >  _public_ int sd_peer_get_session(int fd, char **session) {
> > -        struct ucred ucred;
> > +        struct ucred ucred = {};
> 
> I can't reproduce this warning, but more importantly, why is this
> necessary in this function and not the subsequent noes (which all seem
> to be more or less equivalent)?
I guess this is reported by gcc -Wmaybe-uninitialized

I've experienced these false positive warnings, with different gcc
versions! the -Wmaybe-uninitialized is affected by the optimization
flags and lto, I would say the warnings depend on the code path and how
it's optimized...

-- 
Djalal Harouni
http://opendz.org


More information about the systemd-devel mailing list