qemu: agent: use g_auto for ifname

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>
This commit is contained in:
Ján Tomko 2020-10-05 21:32:49 +02:00
parent 89b43c3e25
commit 196ff56834

View 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;
}