]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Change virIsCapable* to return bool
authorOsier Yang <jyang@redhat.com>
Mon, 6 May 2013 12:45:14 +0000 (20:45 +0800)
committerOsier Yang <jyang@redhat.com>
Mon, 13 May 2013 09:17:26 +0000 (17:17 +0800)
Function name with "aIsB" generally means its return value is
in Bi-state (true/false).

src/node_device/node_device_linux_sysfs.c
src/util/virutil.c
src/util/virutil.h

index 5228a01f445f5e6c22e1d0402d158897d3decfe8..cb2f86ecb4ec4a164e4aa8f181900c0a75702d27 100644 (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);
 
-    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,
index f1dcc6550f6e46f1c280b66b5904fb41d2299a30..bee06a762fd981175ebe8d29208d386434925c64 100644 (file)
@@ -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
index 00ee0c3d0bb11e30b02b21f49777a3c336f15f0d..280a18dc6ee0d1e497a0cfdf04322ba8a5a3f2ed 100644 (file)
@@ -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,