]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONExtractPRManagerInfo: Declare @entry inside the loop
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 22 Oct 2021 05:44:03 +0000 (07:44 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 25 Oct 2021 11:42:39 +0000 (13:42 +0200)
The reason why @entry variable in qemuMonitorJSONExtractPRManagerInfo()
was declared at the top most level was that the variable is used under
the cleanup label.  However, if declared using g_autofree then the
variable can be declared inside the loop it is used in.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
src/qemu/qemu_monitor_json.c

index f59688dfd55138c310780a64c357209d25720752..f7bc6800351f0be9d5e7142d8715a90c25c6a8a0 100644 (file)
@@ -8622,7 +8622,6 @@ static int
 qemuMonitorJSONExtractPRManagerInfo(virJSONValue *reply,
                                     GHashTable *info)
 {
-    qemuMonitorPRManagerInfo *entry = NULL;
     virJSONValue *data;
     int ret = -1;
     size_t i;
@@ -8630,6 +8629,7 @@ qemuMonitorJSONExtractPRManagerInfo(virJSONValue *reply,
     data = virJSONValueObjectGetArray(reply, "return");
 
     for (i = 0; i < virJSONValueArraySize(data); i++) {
+        g_autofree qemuMonitorPRManagerInfo *entry = NULL;
         virJSONValue *prManager = virJSONValueArrayGet(data, i);
         const char *alias;
 
@@ -8652,7 +8652,6 @@ qemuMonitorJSONExtractPRManagerInfo(virJSONValue *reply,
 
     ret = 0;
  cleanup:
-    VIR_FREE(entry);
     return ret;
 
  malformed: