qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 12/19] tests/plugin: prevent uninitialized warning


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v3 12/19] tests/plugin: prevent uninitialized warning
Date: Wed, 26 Feb 2020 14:59:48 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 2/25/20 1:47 PM, Alex Bennée wrote:
From: Chen Qun <address@hidden>

According to the glibc function requirements, we need initialise

GLib?

  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 <address@hidden>
Signed-off-by: Chen Qun <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Message-Id: <address@hidden>
[AJB: uses Thomas's single line allocation]
Signed-off-by: Alex Bennée <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
---
  tests/plugin/bb.c   | 6 +++---
  tests/plugin/insn.c | 3 +--
  2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c
index f30bea08dcc..df19fd359df 100644
--- a/tests/plugin/bb.c
+++ b/tests/plugin/bb.c
@@ -22,9 +22,9 @@ static bool do_inline;
static void plugin_exit(qemu_plugin_id_t id, void *p)
  {
-    g_autofree gchar *out;
-    out = g_strdup_printf("bb's: %" PRIu64", insns: %" PRIu64 "\n",
-                          bb_count, insn_count);
+    g_autofree gchar *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 0a8f5a0000e..a9a6e412373 100644
--- a/tests/plugin/insn.c
+++ b/tests/plugin/insn.c
@@ -44,8 +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;
-    out = g_strdup_printf("insns: %" PRIu64 "\n", insn_count);
+    g_autofree gchar *out = g_strdup_printf("insns: %" PRIu64 "\n", 
insn_count);
      qemu_plugin_outs(out);
  }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]