]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: avoid manual VIR_FREE of a g_autofree pointer in virPCIGetName()
authorLaine Stump <laine@redhat.com>
Sun, 11 Oct 2020 02:56:23 +0000 (22:56 -0400)
committerLaine Stump <laine@redhat.com>
Wed, 21 Oct 2020 19:16:08 +0000 (15:16 -0400)
thisPhysPortID is only used inside a conditional, so reduce its scope
to just the body of that conditional, which will eliminate the need
for the undesirable manual VIR_FREE().

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/util/virpci.c

index 045121c453f722e89a0424e4284ab6ce2b3ca84b..3ca513702e18f6c87b224760388ad5564a7e7b8a 100644 (file)
@@ -2408,7 +2408,6 @@ virPCIGetNetName(const char *device_link_sysfs_path,
 {
     g_autofree char *pcidev_sysfs_net_path = NULL;
     g_autofree char *firstEntryName = NULL;
-    g_autofree char *thisPhysPortID = NULL;
     int ret = -1;
     DIR *dir = NULL;
     struct dirent *entry = NULL;
@@ -2433,12 +2432,13 @@ virPCIGetNetName(const char *device_link_sysfs_path,
          * physportID of this netdev. If not, look for entry[idx].
          */
         if (physPortID) {
+            g_autofree char *thisPhysPortID = NULL;
+
             if (virNetDevGetPhysPortID(entry->d_name, &thisPhysPortID) < 0)
                 goto cleanup;
 
             /* if this one doesn't match, keep looking */
             if (STRNEQ_NULLABLE(physPortID, thisPhysPortID)) {
-                VIR_FREE(thisPhysPortID);
                 /* save the first entry we find to use as a failsafe
                  * in case we don't match the phys_port_id. This is
                  * needed because some NIC drivers (e.g. i40e)