From aa61f7f9c9e5d8a0ab425961a801f6e88f381c96 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Tomko?= Date: Mon, 5 Oct 2020 22:22:00 +0200 Subject: [PATCH] qemu: agent: simplify access to ifaces_ret MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/qemu/qemu_agent.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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"); -- 2.47.2