This lets us conveniently reduce its scope to the outer loop. Signed-off-by: Ján Tomko <jtomko@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 dc989622b9..3b92b2ec33 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"); @@ -2241,8 +2237,6 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, virDomainInterfaceFree(ifaces_ret[i]); } VIR_FREE(ifaces_ret); - g_strfreev(ifname); - goto cleanup; } -- 2.26.2