util: Change virIsCapable* to return bool

Function name with "aIsB" generally means its return value is
in Bi-state (true/false).
This commit is contained in:
Osier Yang 2013-05-06 20:45:14 +08:00
parent b595588fef
commit c56c273be6
3 changed files with 16 additions and 16 deletions

View File

@ -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); 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; d->scsi_host.flags |= VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST;
if (virReadFCHost(NULL, 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; d->scsi_host.flags |= VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS;
if (virReadFCHost(NULL, if (virReadFCHost(NULL,

View File

@ -1704,34 +1704,34 @@ cleanup:
return ret; return ret;
} }
int bool
virIsCapableFCHost(const char *sysfs_prefix, virIsCapableFCHost(const char *sysfs_prefix,
int host) int host)
{ {
char *sysfs_path = NULL; char *sysfs_path = NULL;
int ret = -1; bool ret = false;
if (virAsprintf(&sysfs_path, "%s/host%d", if (virAsprintf(&sysfs_path, "%s/host%d",
sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH, sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH,
host) < 0) { host) < 0) {
virReportOOMError(); virReportOOMError();
return -1; return false;
} }
if (access(sysfs_path, F_OK) == 0) if (access(sysfs_path, F_OK) == 0)
ret = 0; ret = true;
VIR_FREE(sysfs_path); VIR_FREE(sysfs_path);
return ret; return ret;
} }
int bool
virIsCapableVport(const char *sysfs_prefix, virIsCapableVport(const char *sysfs_prefix,
int host) int host)
{ {
char *scsi_host_path = NULL; char *scsi_host_path = NULL;
char *fc_host_path = NULL; char *fc_host_path = NULL;
int ret = -1; int ret = false;
if (virAsprintf(&fc_host_path, if (virAsprintf(&fc_host_path,
"%s/host%d/%s", "%s/host%d/%s",
@ -1739,7 +1739,7 @@ virIsCapableVport(const char *sysfs_prefix,
host, host,
"vport_create") < 0) { "vport_create") < 0) {
virReportOOMError(); virReportOOMError();
return -1; return false;
} }
if (virAsprintf(&scsi_host_path, if (virAsprintf(&scsi_host_path,
@ -1753,7 +1753,7 @@ virIsCapableVport(const char *sysfs_prefix,
if ((access(fc_host_path, F_OK) == 0) || if ((access(fc_host_path, F_OK) == 0) ||
(access(scsi_host_path, F_OK) == 0)) (access(scsi_host_path, F_OK) == 0))
ret = 0; ret = true;
cleanup: cleanup:
VIR_FREE(fc_host_path); VIR_FREE(fc_host_path);
@ -2029,20 +2029,20 @@ virReadFCHost(const char *sysfs_prefix ATTRIBUTE_UNUSED,
return -1; return -1;
} }
int bool
virIsCapableFCHost(const char *sysfs_prefix ATTRIBUTE_UNUSED, virIsCapableFCHost(const char *sysfs_prefix ATTRIBUTE_UNUSED,
int host ATTRIBUTE_UNUSED) int host ATTRIBUTE_UNUSED)
{ {
virReportSystemError(ENOSYS, "%s", _("Not supported on this platform")); virReportSystemError(ENOSYS, "%s", _("Not supported on this platform"));
return -1; return false;
} }
int bool
virIsCapableVport(const char *sysfs_prefix ATTRIBUTE_UNUSED, virIsCapableVport(const char *sysfs_prefix ATTRIBUTE_UNUSED,
int host ATTRIBUTE_UNUSED) int host ATTRIBUTE_UNUSED)
{ {
virReportSystemError(ENOSYS, "%s", _("Not supported on this platform")); virReportSystemError(ENOSYS, "%s", _("Not supported on this platform"));
return -1; return false;
} }
int int

View File

@ -143,8 +143,8 @@ int virReadFCHost(const char *sysfs_prefix,
char **result) char **result)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
int virIsCapableFCHost(const char *sysfs_prefix, int host); bool virIsCapableFCHost(const char *sysfs_prefix, int host);
int virIsCapableVport(const char *sysfs_prefix, int host); bool virIsCapableVport(const char *sysfs_prefix, int host);
enum { enum {
VPORT_CREATE, VPORT_CREATE,