From: Ján Tomko Date: Mon, 5 Oct 2020 20:22:00 +0000 (+0200) Subject: qemu: agent: simplify access to ifaces_ret X-Git-Tag: v6.9.0-rc1~254 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa61f7f9c9e5d8a0ab425961a801f6e88f381c96;p=thirdparty%2Flibvirt.git qemu: agent: simplify access to ifaces_ret We have a local 'iface' variable that contains the same value eventually. Initialize it early instead of indexing two more times. Signed-off-by: Ján Tomko Reviewed-by: Jonathon Jongsma Reviewed-by: Neal Gompa --- diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index a09fb4da2a..721ff55fff 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2176,15 +2176,13 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0) goto error; - ifaces_ret[ifaces_count - 1] = g_new0(virDomainInterface, 1); + iface = g_new0(virDomainInterface, 1); + ifaces_ret[ifaces_count - 1] = iface; - if (virHashAddEntry(ifaces_store, ifname_s, - ifaces_ret[ifaces_count - 1]) < 0) + if (virHashAddEntry(ifaces_store, ifname_s, iface) < 0) goto error; - iface = ifaces_ret[ifaces_count - 1]; iface->naddrs = 0; - iface->name = g_strdup(ifname_s); hwaddr = virJSONValueObjectGetString(tmp_iface, "hardware-address");