Skip to contentSkip to conversation

tests/plugin/syscall.c: fix compiler warnings

PATCH Applied Juro Bystricky 3 participants 5 messages Nov 28, 2021 – Dec 2, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/plugin/syscall.c: fix compiler warnings

Fix compiler warnings. The warnings can result in a broken build. This patch fixes warnings such as:

In file included from /usr/include/glib-2.0/glib.h:111,

                 from ../tests/plugin/syscall.c:13:

../tests/plugin/syscall.c: In function ‘print_entry’:
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: error: ‘out’ may be
used uninitialized in this function [-Werror=maybe-uninitialized]
g_free (*pp);
^~~~~~~~~~~~
../tests/plugin/syscall.c:82:23: note: ‘out’ was declared here

     g_autofree gchar *out;
                       ^~~
In file included from /usr/include/glib-2.0/glib.h:111,
                 from ../tests/plugin/syscall.c:13:

../tests/plugin/syscall.c: In function ‘vcpu_syscall_ret’:
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: error: ‘out’ may be
used uninitialized in this function [-Werror=maybe-uninitialized]
g_free (*pp);
^~~~~~~~~~~~
../tests/plugin/syscall.c:73:27: note: ‘out’ was declared here

         g_autofree gchar *out;
                           ^~~

cc1: all warnings being treated as errors

---
 tests/plugin/syscall.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
tests/plugin/syscall.c +3 -5
index 484b48de49..96040c578f 100644
@@ -70,19 +70,17 @@ static void vcpu_syscall_ret(qemu_plugin_id_t id, unsigned int vcpu_idx,
         }
         g_mutex_unlock(&lock);
     } else {
-        g_autofree gchar *out;
-        out = g_strdup_printf("syscall #%" PRIi64 " returned -> %" PRIi64 "\n",
-                num, ret);
+        g_autofree gchar *out = g_strdup_printf(
+             "syscall #%" PRIi64 " returned -> %" PRIi64 "\n", num, ret);
         qemu_plugin_outs(out);
     }
 }
 
 static void print_entry(gpointer val, gpointer user_data)
 {
-    g_autofree gchar *out;
     SyscallStats *entry = (SyscallStats *) val;
     int64_t syscall_num = entry->num;
-    out = g_strdup_printf(
+    g_autofree gchar *out = g_strdup_printf(
         "%-13" PRIi64 "%-6" PRIi64 " %" PRIi64 "\n",
         syscall_num, entry->calls, entry->errors);
     qemu_plugin_outs(out);
Signature · 1 line
2.27.0
Applied
#1 lore raw
Quoted 2 lines · Juro Bystricky

Fix compiler warnings. The warnings can result in a broken build. This patch fixes warnings such as:

Queued to for-6.2/more-misc-fixes, thanks.

Signature · 1 line
Alex Bennée
#2 lore raw
Quoted 7 lines · Alex Bennée
Quoted 2 lines · Juro Bystricky

Fix compiler warnings. The warnings can result in a broken build. This patch fixes warnings such as:

Queued to for-6.2/more-misc-fixes, thanks.

I wondered if this single patch would justify delaying the 6.2 release by one week, but then I noticed the IDE pull request, so let it be...

Note, -Werror=maybe-uninitialized forces an ugly alignment style to the g_autofree + g_strdup_printf() combination.

#3 lore raw
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Alex Bennée

Juro Bystricky <[email protected]> writes:

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Fix compiler warnings. The warnings can result in a broken build. This patch fixes warnings such as:

Queued to for-6.2/more-misc-fixes, thanks.

I wondered if this single patch would justify delaying the 6.2 release by one week, but then I noticed the IDE pull request, so let it be...

Already in - as I had a PR in flight ;-)

Quoted 5 lines

Note, -Werror=maybe-uninitialized forces an ugly alignment style to the g_autofree + g_strdup_printf() combination.

Thanks anyway.

Signature · 1 line
Alex Bennée
#4 lore raw
Quoted 8 lines · Alex Bennée
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Alex Bennée
Quoted 2 lines · Juro Bystricky

Fix compiler warnings. The warnings can result in a broken build. This patch fixes warnings such as:

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Queued to for-6.2/more-misc-fixes, thanks.

I wondered if this single patch would justify delaying the 6.2 release by one week, but then I noticed the IDE pull request, so let it be...

Already in - as I had a PR in flight ;-)

Oops, mails out of sync...