mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
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.
This commit is contained in:
parent
ccf2d0847b
commit
4186f92935
15
src/driver.h
15
src/driver.h
@ -47,17 +47,20 @@ typedef enum {
|
|||||||
|
|
||||||
|
|
||||||
/* Internal feature-detection macro. Don't call drv->supports_feature
|
/* 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:
|
* Returns:
|
||||||
* >= 1 Feature is supported.
|
* != 0 Feature is supported.
|
||||||
* 0 Feature is not supported.
|
* 0 Feature is not supported.
|
||||||
* -1 Error.
|
|
||||||
*/
|
*/
|
||||||
# define VIR_DRV_SUPPORTS_FEATURE(drv,conn,feature) \
|
# define VIR_DRV_SUPPORTS_FEATURE(drv,conn,feature) \
|
||||||
((drv)->supports_feature ? (drv)->supports_feature((conn),(feature)) : 0)
|
((drv)->supports_feature ? \
|
||||||
|
(drv)->supports_feature((conn), (feature)) > 0 : 0)
|
||||||
|
|
||||||
typedef virDrvOpenStatus
|
typedef virDrvOpenStatus
|
||||||
(*virDrvOpen) (virConnectPtr conn,
|
(*virDrvOpen) (virConnectPtr conn,
|
||||||
|
@ -1605,7 +1605,10 @@ virDrvSupportsFeature (virConnectPtr conn, int feature)
|
|||||||
return (-1);
|
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)
|
if (ret < 0)
|
||||||
virDispatchError(conn);
|
virDispatchError(conn);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user