[PATCH 06/19] storage: Fix return value checks for virAsprintf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the < 0 rather than == -1 (consistently) for virAsprintf errors.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_backend_logical.c  | 2 +-
 src/storage/storage_backend_rbd.c      | 8 ++++----
 src/storage/storage_backend_sheepdog.c | 4 ++--
 src/storage/storage_backend_zfs.c      | 4 ++--
 src/storage/storage_util.c             | 6 +++---
 src/test/test_driver.c                 | 9 +++------
 6 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index ed26c24..67f70e5 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -948,7 +948,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
     VIR_FREE(vol->target.path);
     if (virAsprintf(&vol->target.path, "%s/%s",
                     pool->def->target.path,
-                    vol->name) == -1)
+                    vol->name) < 0)
         return -1;
 
     cmd = virCommandNewArgList(LVCREATE,
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index c806d6d..7b8887b 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -404,13 +404,13 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
     VIR_FREE(vol->target.path);
     if (virAsprintf(&vol->target.path, "%s/%s",
                     pool->def->source.name,
-                    vol->name) == -1)
+                    vol->name) < 0)
         goto cleanup;
 
     VIR_FREE(vol->key);
     if (virAsprintf(&vol->key, "%s/%s",
                     pool->def->source.name,
-                    vol->name) == -1)
+                    vol->name) < 0)
         goto cleanup;
 
     ret = 0;
@@ -662,13 +662,13 @@ virStorageBackendRBDCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
     VIR_FREE(vol->target.path);
     if (virAsprintf(&vol->target.path, "%s/%s",
                     pool->def->source.name,
-                    vol->name) == -1)
+                    vol->name) < 0)
         return -1;
 
     VIR_FREE(vol->key);
     if (virAsprintf(&vol->key, "%s/%s",
                     pool->def->source.name,
-                    vol->name) == -1)
+                    vol->name) < 0)
         return -1;
 
     return 0;
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index a9a2301..b55d96a 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -249,7 +249,7 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     VIR_FREE(vol->key);
     if (virAsprintf(&vol->key, "%s/%s",
-                    pool->def->source.name, vol->name) == -1)
+                    pool->def->source.name, vol->name) < 0)
         return -1;
 
     VIR_FREE(vol->target.path);
@@ -374,7 +374,7 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     VIR_FREE(vol->key);
     if (virAsprintf(&vol->key, "%s/%s",
-                    pool->def->source.name, vol->name) == -1)
+                    pool->def->source.name, vol->name) < 0)
         goto cleanup;
 
     VIR_FREE(vol->target.path);
diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index 004d95a..c6dae71 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -89,7 +89,7 @@ virStorageBackendZFSCheckPool(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
     char *devpath;
 
     if (virAsprintf(&devpath, "/dev/zvol/%s",
-                    pool->def->source.name) == -1)
+                    pool->def->source.name) < 0)
         return -1;
     *isActive = virFileIsDir(devpath);
     VIR_FREE(devpath);
@@ -322,7 +322,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     VIR_FREE(vol->target.path);
     if (virAsprintf(&vol->target.path, "%s/%s",
-                    pool->def->target.path, vol->name) == -1)
+                    pool->def->target.path, vol->name) < 0)
         return -1;
 
     if (VIR_STRDUP(vol->key, vol->target.path) < 0)
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 43f3561..08dca94 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -1982,7 +1982,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
     while ((direrr = virDirRead(dh, &dent, NULL)) > 0) {
         if (virAsprintf(&stablepath, "%s/%s",
                         pool->def->target.path,
-                        dent->d_name) == -1) {
+                        dent->d_name) < 0) {
             VIR_DIR_CLOSE(dh);
             return NULL;
         }
@@ -2082,7 +2082,7 @@ virStorageBackendVolCreateLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
     VIR_FREE(vol->target.path);
     if (virAsprintf(&vol->target.path, "%s/%s",
                     pool->def->target.path,
-                    vol->name) == -1)
+                    vol->name) < 0)
         return -1;
 
     if (virFileExists(vol->target.path)) {
@@ -3553,7 +3553,7 @@ virStorageBackendRefreshLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
         vol->target.format = VIR_STORAGE_FILE_RAW; /* Real value is filled in during probe */
         if (virAsprintf(&vol->target.path, "%s/%s",
                         pool->def->target.path,
-                        vol->name) == -1)
+                        vol->name) < 0)
             goto cleanup;
 
         if (VIR_STRDUP(vol->key, vol->target.path) < 0)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 460aa88..8d03bdb 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1069,8 +1069,7 @@ testOpenVolumesForPool(const char *file,
 
         if (def->target.path == NULL) {
             if (virAsprintf(&def->target.path, "%s/%s",
-                            obj->def->target.path,
-                            def->name) == -1)
+                            obj->def->target.path, def->name) < 0)
                 goto error;
         }
 
@@ -4946,8 +4945,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
     }
 
     if (virAsprintf(&privvol->target.path, "%s/%s",
-                    obj->def->target.path,
-                    privvol->name) == -1)
+                    obj->def->target.path, privvol->name) < 0)
         goto cleanup;
 
     if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 ||
@@ -5015,8 +5013,7 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
     obj->def->available = (obj->def->capacity - obj->def->allocation);
 
     if (virAsprintf(&privvol->target.path, "%s/%s",
-                    obj->def->target.path,
-                    privvol->name) == -1)
+                    obj->def->target.path, privvol->name) < 0)
         goto cleanup;
 
     if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 ||
-- 
2.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux