qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Robert Foley <robert.foley@linaro.org>
To: Thomas Huth <thuth@redhat.com>
Cc: qemu-trivial@nongnu.org, peter.maydell@linaro.org,
	mrezanin@redhat.com, "Alex Bennée" <alex.bennee@linaro.org>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] test-logging: Fix -Werror=maybe-uninitialized warning
Date: Tue, 21 Jan 2020 10:03:18 -0500	[thread overview]
Message-ID: <CAEyhzFuJoFYy_aE6fq1ieHcEcgWQCUkwHmGNQ0gJiazusH3BAw@mail.gmail.com> (raw)
In-Reply-To: <14ba746f-97c3-1ae3-c836-ad2e3e213756@redhat.com>

Good catch.
Reviewed-by: Robert Foley <robert.foley@linaro.org>

On Tue, 21 Jan 2020 at 04:58, Thomas Huth <thuth@redhat.com> wrote:
>
> On 21/01/2020 10.28, mrezanin@redhat.com wrote:
> > From: Miroslav Rezanina <mrezanin@redhat.com>
> >
> > Checking for uninitialized variables raises warning for file path
> > variables in test_logfile_write and test_logfile_lock functions.
> >
> > To suppress this warning, initialize varibles to NULL. This is safe
> > change as result of g_build_filename is stored to them before any usage.
> >
> > Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
> > ---
> >  tests/test-logging.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/tests/test-logging.c b/tests/test-logging.c
> > index 1e646f0..6387e49 100644
> > --- a/tests/test-logging.c
> > +++ b/tests/test-logging.c
> > @@ -114,8 +114,8 @@ static void test_logfile_write(gconstpointer data)
> >      QemuLogFile *logfile2;
> >      gchar const *dir = data;
> >      Error *err = NULL;
> > -    g_autofree gchar *file_path;
> > -    g_autofree gchar *file_path1;
> > +    g_autofree gchar *file_path = NULL;
> > +    g_autofree gchar *file_path1 = NULL;
> >      FILE *orig_fd;
> >
> >      /*
> > @@ -157,7 +157,7 @@ static void test_logfile_lock(gconstpointer data)
> >      FILE *logfile;
> >      gchar const *dir = data;
> >      Error *err = NULL;
> > -    g_autofree gchar *file_path;
> > +    g_autofree gchar *file_path = NULL;
> >
> >      file_path = g_build_filename(dir, "qemu_test_logfile_lock0.log", NULL);
>
> Right. The glib documentation clearly states that "the variable must be
> initialized", see:
>
> https://developer.gnome.org/glib/stable/glib-Miscellaneous-Macros.html#g-autofree
>
> So this is the right thing to do here!
>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
>


  reply	other threads:[~2020-01-21 15:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-21  9:28 [PATCH 0/2] Prevent uninitialized warnings mrezanin
2020-01-21  9:28 ` [PATCH 1/2] test-logging: Fix -Werror=maybe-uninitialized warning mrezanin
2020-01-21  9:58   ` Thomas Huth
2020-01-21 15:03     ` Robert Foley [this message]
2020-01-21  9:28 ` [PATCH 2/2] aspeed/i2c: Prevent uninitialized warning mrezanin
2020-01-21 10:02   ` Thomas Huth
2020-01-21 10:44     ` Cédric Le Goater
2020-01-21 10:57       ` Miroslav Rezanina
2020-01-21 11:43       ` Thomas Huth
2020-02-06 10:13   ` Laurent Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEyhzFuJoFYy_aE6fq1ieHcEcgWQCUkwHmGNQ0gJiazusH3BAw@mail.gmail.com \
    --to=robert.foley@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=mrezanin@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).