[PATCH 09/13] qemuMonitorJSONExtractPRManagerInfo: Declare @entry inside the loop

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

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_monitor_json.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index f59688dfd5..f7bc680035 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -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:
-- 
2.32.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux