]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virpci: Clarify lifetime of temporary object
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 23 Aug 2021 10:47:07 +0000 (12:47 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 26 Aug 2021 07:16:44 +0000 (09:16 +0200)
The virPCIDeviceIsBehindSwitchLackingACS() function checks
whether given PCI device is not behind a switch that lacks ACS.
It does so by starting at given device and traversing up, one
parent at time towards the root. The parent device is obtained
via virPCIDeviceGetParent() which allocates new virPCIDevice
structure. For freeing the structure we use g_autoptr() and a
temporary variable @tmp. However, Clang fails to understand our
clever algorithm and complains that the variable is set but never
used. This is obviously a false positive, but using a small trick
we can shut Clang up.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/util/virpci.c

index 915a4903cab8d608388e2abe008620a9a37c4da5..f307580a53119c416909c57ded0ec5a5c36d0e9d 100644 (file)
@@ -2150,8 +2150,8 @@ virPCIDeviceIsBehindSwitchLackingACS(virPCIDevice *dev)
                 return 1;
         }
 
-        tmp = parent;
-        ret = virPCIDeviceGetParent(parent, &parent);
+        tmp = g_steal_pointer(&parent);
+        ret = virPCIDeviceGetParent(tmp, &parent);
         if (ret < 0)
             return -1;
     } while (parent);