]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: fix virDevicePCIAddressEqual args
authorLaine Stump <laine@laine.org>
Thu, 11 Oct 2012 16:34:14 +0000 (12:34 -0400)
committerLaine Stump <laine@laine.org>
Mon, 15 Oct 2012 08:03:06 +0000 (04:03 -0400)
This function really should have been taking virDevicePCIAddress*
instead of the inefficient virDevicePCIAddress (results in copying two
entire structs onto the stack rather than just two pointers), and
returning a bool true/false (not matching is not necessarily a
"failure", as a -1 return would imply, and also using "if
(!virDevicePCIAddressEqual(x, y))" to mean "if x == y" is just a bit
counterintuitive).

src/conf/device_conf.c
src/conf/device_conf.h
src/network/bridge_driver.c

index a852960be43f461ec27fd4ff8293dc746a089d41..7b97f455877d75ea99c0b8ad0853ef39e5784fbb 100644 (file)
@@ -130,18 +130,15 @@ virDevicePCIAddressFormat(virBufferPtr buf,
     return 0;
 }
 
-int
-virDevicePCIAddressEqual(virDevicePCIAddress addr1,
-                         virDevicePCIAddress addr2)
+bool
+virDevicePCIAddressEqual(virDevicePCIAddress *addr1,
+                         virDevicePCIAddress *addr2)
 {
-    int ret = -1;
-
-    if (addr1.domain == addr2.domain &&
-        addr1.bus == addr2.bus &&
-        addr1.slot == addr2.slot &&
-        addr1.function == addr2.function) {
-        ret = 0;
+    if (addr1->domain == addr2->domain &&
+        addr1->bus == addr2->bus &&
+        addr1->slot == addr2->slot &&
+        addr1->function == addr2->function) {
+        return true;
     }
-
-    return ret;
+    return false;
 }
index 26d5637e27ea352bb88720f3ebe688372e25dd67..5318738a1b8157a3848d84adfe818a8134aa7ef3 100644 (file)
@@ -59,8 +59,8 @@ int virDevicePCIAddressFormat(virBufferPtr buf,
                               virDevicePCIAddress addr,
                               bool includeTypeInAddr);
 
-int virDevicePCIAddressEqual(virDevicePCIAddress addr1,
-                             virDevicePCIAddress addr2);
+bool virDevicePCIAddressEqual(virDevicePCIAddress *addr1,
+                              virDevicePCIAddress *addr2);
 
 
 VIR_ENUM_DECL(virDeviceAddressPciMulti)
index e1846ee6d3fee2a75429df952e8121fad111f7f2..0c4b0b009282819deb9443e47e0b59aac9f47f8d 100644 (file)
@@ -3820,8 +3820,8 @@ networkNotifyActualDevice(virDomainNetDefPtr iface)
         for (ii = 0; ii < netdef->nForwardIfs; ii++) {
             if (netdef->forwardIfs[ii].type
                 == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI &&
-                (virDevicePCIAddressEqual(hostdev->source.subsys.u.pci,
-                                          netdef->forwardIfs[ii].device.pci) == 0)) {
+                virDevicePCIAddressEqual(&hostdev->source.subsys.u.pci,
+                                         &netdef->forwardIfs[ii].device.pci)) {
                 dev = &netdef->forwardIfs[ii];
                 break;
             }
@@ -3972,8 +3972,8 @@ networkReleaseActualDevice(virDomainNetDefPtr iface)
         for (ii = 0; ii < netdef->nForwardIfs; ii++) {
             if (netdef->forwardIfs[ii].type
                 == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI &&
-                (virDevicePCIAddressEqual(hostdev->source.subsys.u.pci,
-                                          netdef->forwardIfs[ii].device.pci) == 0)) {
+                virDevicePCIAddressEqual(&hostdev->source.subsys.u.pci,
+                                          &netdef->forwardIfs[ii].device.pci)) {
                 dev = &netdef->forwardIfs[ii];
                 break;
             }