qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: kuhn.chenqun@huawei.com, qemu-devel@nongnu.org, alex.bennee@linaro.org
Cc: qemu-trivial@nongnu.org, richard.henderson@linaro.org,
	zhang.zhanghailiang@huawei.com
Subject: Re: [PATCH] tests/plugin: prevent uninitialized warning
Date: Thu, 6 Feb 2020 11:19:38 +0100	[thread overview]
Message-ID: <85dc652f-1a54-bac4-6ed3-f6e6d6dd08a0@redhat.com> (raw)
In-Reply-To: <20200206093238.203984-1-kuhn.chenqun@huawei.com>

On 06/02/2020 10.32, kuhn.chenqun@huawei.com wrote:
> From: Chen Qun <kuhn.chenqun@huawei.com>
> 
> According to the glibc function requirements, we need initialise
>  the variable. Otherwise there will be compilation warnings:
> 
> glib-autocleanups.h:28:3: warning: ‘out’ may be
> used uninitialized in this function [-Wmaybe-uninitialized]
>    g_free (*pp);
>    ^~~~~~~~~~~~
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
>  tests/plugin/bb.c   | 2 +-
>  tests/plugin/insn.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c
> index f30bea08dc..8b9da23a04 100644
> --- a/tests/plugin/bb.c
> +++ b/tests/plugin/bb.c
> @@ -22,7 +22,7 @@ static bool do_inline;
>  
>  static void plugin_exit(qemu_plugin_id_t id, void *p)
>  {
> -    g_autofree gchar *out;
> +    g_autofree gchar *out = NULL;
>      out = g_strdup_printf("bb's: %" PRIu64", insns: %" PRIu64 "\n",
>                            bb_count, insn_count);
>      qemu_plugin_outs(out);
> diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c
> index 0a8f5a0000..c83b1c0157 100644
> --- a/tests/plugin/insn.c
> +++ b/tests/plugin/insn.c
> @@ -44,7 +44,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
>  
>  static void plugin_exit(qemu_plugin_id_t id, void *p)
>  {
> -    g_autofree gchar *out;
> +    g_autofree gchar *out = NULL;
>      out = g_strdup_printf("insns: %" PRIu64 "\n", insn_count);
>      qemu_plugin_outs(out);
>  }

Just a matter of taste, but I think in these simple cases, it would be
nicer to put everything in one line, e.g.:

    g_autofree gchar *out = g_strdup_printf("insns: %" PRIu64 "\n",
                                            insn_count);

Anyway,
Reviewed-by: Thomas Huth <thuth@redhat.com>



  reply	other threads:[~2020-02-06 10:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06  9:32 [PATCH] tests/plugin: prevent uninitialized warning kuhn.chenqun
2020-02-06 10:19 ` Thomas Huth [this message]
2020-02-06 12:45 ` Alex Bennée
2020-02-06 13:25   ` Chenqun (kuhn)
2020-02-06 16:22     ` Alex Bennée

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=85dc652f-1a54-bac4-6ed3-f6e6d6dd08a0@redhat.com \
    --to=thuth@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=kuhn.chenqun@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=zhang.zhanghailiang@huawei.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).