]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Change return value of VIR_DRV_SUPPORTS_FEATURE to bool
authorJiri Denemark <jdenemar@redhat.com>
Fri, 3 Dec 2010 08:31:48 +0000 (09:31 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 6 Dec 2010 09:09:00 +0000 (10:09 +0100)
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
src/libvirt.c

index b770e5e569867c81d57ea49bc6d991af0073822e..75305fede5dff1865ff20e8094192b45f3a18fc2 100644 (file)
@@ -47,17 +47,20 @@ typedef enum {
 
 
 /* Internal feature-detection macro.  Don't call drv->supports_feature
- * directly, because it may be NULL, use this macro instead.
+ * directly if you don't have to, because it may be NULL, use this macro
+ * instead.
  *
- * Note that you must check for errors.
+ * Note that this treats a possible error returned by drv->supports_feature
+ * the same as not supported. If you care about the error, call
+ * drv->supports_feature directly.
  *
  * 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,
index b4951c233dad3839bc9eb3821ffc93232eeb4d02..4188b452eafa96f505ba64b955bb83fe8ece9162 100644 (file)
@@ -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);