[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] Change return value of VIR_DRV_SUPPORTS_FEATURE to bool



virDrvSupportsFeature API is allowed to return -1 on error while all but
one uses of VIR_DRV_SUPPORTS_FEATURE only check for (non)zero return
value. Let's make this macro return zero on error, which is what
everyone expects anyway.
---
 src/driver.h  |    8 ++++----
 src/libvirt.c |    5 ++++-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/driver.h b/src/driver.h
index b770e5e..e797a75 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -52,12 +52,12 @@ typedef enum {
  * Note that you must check for errors.
  *
  * Returns:
- *   >= 1  Feature is supported.
+ *   != 0  Feature is supported.
  *   0     Feature is not supported.
- *   -1    Error.
  */
-# define VIR_DRV_SUPPORTS_FEATURE(drv,conn,feature)                      \
-    ((drv)->supports_feature ? (drv)->supports_feature((conn),(feature)) : 0)
+# define VIR_DRV_SUPPORTS_FEATURE(drv,conn,feature)                         \
+    ((drv)->supports_feature ?                                              \
+        (drv)->supports_feature((conn), (feature)) > 0 : 0)
 
 typedef virDrvOpenStatus
         (*virDrvOpen)			(virConnectPtr conn,
diff --git a/src/libvirt.c b/src/libvirt.c
index b4951c2..4188b45 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1605,7 +1605,10 @@ virDrvSupportsFeature (virConnectPtr conn, int feature)
         return (-1);
     }
 
-    ret = VIR_DRV_SUPPORTS_FEATURE (conn->driver, conn, feature);
+    if (!conn->driver->supports_feature)
+        ret = 0;
+    else
+        ret = conn->driver->supports_feature(conn, feature);
 
     if (ret < 0)
         virDispatchError(conn);
-- 
1.7.3.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]