]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: agent: simplify access to ifaces_ret
authorJán Tomko <jtomko@redhat.com>
Mon, 5 Oct 2020 20:22:00 +0000 (22:22 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 8 Oct 2020 09:16:08 +0000 (11:16 +0200)
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 <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
src/qemu/qemu_agent.c

index a09fb4da2ab45c9c07805a6ac599fd1c1a184c47..721ff55fff88ccd2da1b9ab7eedbba1ee16b7f16 100644 (file)
@@ -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");