]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: agent: use g_auto for ifname
authorJán Tomko <jtomko@redhat.com>
Mon, 5 Oct 2020 19:32:49 +0000 (21:32 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 8 Oct 2020 09:16:08 +0000 (11:16 +0200)
This lets us conveniently reduce its scope to the outer loop.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
src/qemu/qemu_agent.c

index 0394a725182807616dac63775c28b98700ced0d0..b11f8afde7db7d8b33e95851610718c4e50bc657 100644 (file)
@@ -2127,7 +2127,6 @@ qemuAgentGetInterfaces(qemuAgentPtr agent,
     size_t ifaces_count = 0;
     virDomainInterfacePtr *ifaces_ret = NULL;
     virHashTablePtr ifaces_store = NULL;
-    char **ifname = NULL;
 
     /* Hash table to handle the interface alias */
     if (!(ifaces_store = virHashCreate(ifaces_count, NULL))) {
@@ -2158,6 +2157,7 @@ qemuAgentGetInterfaces(qemuAgentPtr agent,
         virJSONValuePtr ip_addr_arr = NULL;
         const char *hwaddr, *ifname_s, *name = NULL;
         virDomainInterfacePtr iface = NULL;
+        g_auto(GStrv) ifname = NULL;
         size_t addrs_count = 0;
 
         /* interface name is required to be presented */
@@ -2194,10 +2194,6 @@ qemuAgentGetInterfaces(qemuAgentPtr agent,
             iface->hwaddr = g_strdup(hwaddr);
         }
 
-        /* Has to be freed for each interface. */
-        g_strfreev(ifname);
-        ifname = NULL;
-
         /* as well as IP address which - moreover -
          * can be presented multiple times */
         ip_addr_arr = virJSONValueObjectGet(tmp_iface, "ip-addresses");
@@ -2242,8 +2238,6 @@ qemuAgentGetInterfaces(qemuAgentPtr agent,
             virDomainInterfaceFree(ifaces_ret[i]);
     }
     VIR_FREE(ifaces_ret);
-    g_strfreev(ifname);
-
     goto cleanup;
 }