[libvirt PATCHv2 06/16] qemu: agent: use g_auto for ifname

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

 



This lets us conveniently reduce its scope to the outer loop.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
Reviewed-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 src/qemu/qemu_agent.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 0394a72518..b11f8afde7 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -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;
 }
 
-- 
2.26.2




[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