[libvirt PATCH v2 3/7] util: simplify call to virPCIDeviceDetectPowerManagementReset()

Laine Stump laine at redhat.com
Fri Dec 11 15:47:24 UTC 2020


This function returned an int, but would only return 0 or 1, and the
one place it was called would just use !! to convert that value to a
bool. Change the function to directly return bool instead.

Signed-off-by: Laine Stump <laine at redhat.com>
---
 src/util/virpci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 403ef1ec8e..31622cddfa 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -608,7 +608,7 @@ virPCIDeviceDetectFunctionLevelReset(virPCIDevicePtr dev, int cfgfd)
  * and that a D3hot->D0 transition will results in a full
  * internal reset, not just a soft reset.
  */
-static unsigned int
+static bool
 virPCIDeviceDetectPowerManagementReset(virPCIDevicePtr dev, int cfgfd)
 {
     if (dev->pci_pm_cap_pos) {
@@ -618,13 +618,13 @@ virPCIDeviceDetectPowerManagementReset(virPCIDevicePtr dev, int cfgfd)
         ctl = virPCIDeviceRead32(dev, cfgfd, dev->pci_pm_cap_pos + PCI_PM_CTRL);
         if (!(ctl & PCI_PM_CTRL_NO_SOFT_RESET)) {
             VIR_DEBUG("%s %s: detected PM reset capability", dev->id, dev->name);
-            return 1;
+            return true;
         }
     }
 
     VIR_DEBUG("%s %s: no PM reset capability found", dev->id, dev->name);
 
-    return 0;
+    return false;
 }
 
 /* Any active devices on the same domain/bus ? */
@@ -888,7 +888,7 @@ virPCIDeviceInit(virPCIDevicePtr dev, int cfgfd)
     dev->pcie_cap_pos   = virPCIDeviceFindCapabilityOffset(dev, cfgfd, PCI_CAP_ID_EXP);
     dev->pci_pm_cap_pos = virPCIDeviceFindCapabilityOffset(dev, cfgfd, PCI_CAP_ID_PM);
     dev->has_flr = virPCIDeviceDetectFunctionLevelReset(dev, cfgfd);
-    dev->has_pm_reset = !!virPCIDeviceDetectPowerManagementReset(dev, cfgfd);
+    dev->has_pm_reset = virPCIDeviceDetectPowerManagementReset(dev, cfgfd);
 
     return 0;
 }
-- 
2.28.0




More information about the libvir-list mailing list