From: Osier Yang Date: Mon, 6 May 2013 12:45:14 +0000 (+0800) Subject: util: Change virIsCapable* to return bool X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c56c273be676d37e6fda5f837de8a7b621ed5f28;p=libvirt.git util: Change virIsCapable* to return bool Function name with "aIsB" generally means its return value is in Bi-state (true/false). --- diff --git a/src/node_device/node_device_linux_sysfs.c b/src/node_device/node_device_linux_sysfs.c index 5228a01f44..cb2f86ecb4 100644 --- a/src/node_device/node_device_linux_sysfs.c +++ b/src/node_device/node_device_linux_sysfs.c @@ -47,7 +47,7 @@ detect_scsi_host_caps(union _virNodeDevCapData *d) VIR_DEBUG("Checking if host%d is an FC HBA", d->scsi_host.host); - if (virIsCapableFCHost(NULL, d->scsi_host.host) == 0) { + if (virIsCapableFCHost(NULL, d->scsi_host.host)) { d->scsi_host.flags |= VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST; if (virReadFCHost(NULL, @@ -76,7 +76,7 @@ detect_scsi_host_caps(union _virNodeDevCapData *d) } } - if (virIsCapableVport(NULL, d->scsi_host.host) == 0) { + if (virIsCapableVport(NULL, d->scsi_host.host)) { d->scsi_host.flags |= VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS; if (virReadFCHost(NULL, diff --git a/src/util/virutil.c b/src/util/virutil.c index f1dcc6550f..bee06a762f 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -1704,34 +1704,34 @@ cleanup: return ret; } -int +bool virIsCapableFCHost(const char *sysfs_prefix, int host) { char *sysfs_path = NULL; - int ret = -1; + bool ret = false; if (virAsprintf(&sysfs_path, "%s/host%d", sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH, host) < 0) { virReportOOMError(); - return -1; + return false; } if (access(sysfs_path, F_OK) == 0) - ret = 0; + ret = true; VIR_FREE(sysfs_path); return ret; } -int +bool virIsCapableVport(const char *sysfs_prefix, int host) { char *scsi_host_path = NULL; char *fc_host_path = NULL; - int ret = -1; + int ret = false; if (virAsprintf(&fc_host_path, "%s/host%d/%s", @@ -1739,7 +1739,7 @@ virIsCapableVport(const char *sysfs_prefix, host, "vport_create") < 0) { virReportOOMError(); - return -1; + return false; } if (virAsprintf(&scsi_host_path, @@ -1753,7 +1753,7 @@ virIsCapableVport(const char *sysfs_prefix, if ((access(fc_host_path, F_OK) == 0) || (access(scsi_host_path, F_OK) == 0)) - ret = 0; + ret = true; cleanup: VIR_FREE(fc_host_path); @@ -2029,20 +2029,20 @@ virReadFCHost(const char *sysfs_prefix ATTRIBUTE_UNUSED, return -1; } -int +bool virIsCapableFCHost(const char *sysfs_prefix ATTRIBUTE_UNUSED, int host ATTRIBUTE_UNUSED) { virReportSystemError(ENOSYS, "%s", _("Not supported on this platform")); - return -1; + return false; } -int +bool virIsCapableVport(const char *sysfs_prefix ATTRIBUTE_UNUSED, int host ATTRIBUTE_UNUSED) { virReportSystemError(ENOSYS, "%s", _("Not supported on this platform")); - return -1; + return false; } int diff --git a/src/util/virutil.h b/src/util/virutil.h index 00ee0c3d0b..280a18dc6e 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -143,8 +143,8 @@ int virReadFCHost(const char *sysfs_prefix, char **result) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); -int virIsCapableFCHost(const char *sysfs_prefix, int host); -int virIsCapableVport(const char *sysfs_prefix, int host); +bool virIsCapableFCHost(const char *sysfs_prefix, int host); +bool virIsCapableVport(const char *sysfs_prefix, int host); enum { VPORT_CREATE,