]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Fix return value checks for virAsprintf
authorJohn Ferlan <jferlan@redhat.com>
Mon, 8 May 2017 11:30:19 +0000 (07:30 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 21 Jul 2017 18:51:47 +0000 (14:51 -0400)
Use the < 0 rather than == -1 (consistently) for virAsprintf errors.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/storage/storage_backend_logical.c
src/storage/storage_backend_rbd.c
src/storage/storage_backend_sheepdog.c
src/storage/storage_backend_zfs.c
src/storage/storage_util.c
src/test/test_driver.c

index ed26c24509cec933924e54dfedd7cc97114b7509..67f70e551729a5aa0270f5d8a3c10fa3daf222e8 100644 (file)
@@ -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,
index c806d6d3047481b7908f2297d2e29f379ca46ac7..7b8887b9308200cc6dc49166d93ead9d06c4c726 100644 (file)
@@ -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;
index a9a2301e63630298ba1f515c67ce363362e88421..b55d96a7e2284a72c660bc7b2149edd2819842fd 100644 (file)
@@ -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);
index 004d95a5385b508cd3ef979844c37994dbbe4828..c6dae7183d3420635a0315c7a8a9772bb39ff70b 100644 (file)
@@ -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)
index 493c651b7f5484d422e30f96f820e085d51e151f..e1fe162ed935b357ef20b8902a49d51cae79e0f9 100644 (file)
@@ -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)) {
@@ -3555,7 +3555,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)
index 45e9adc8ba80e69c3f2b6e28bdbab98d64ee611a..0fefa89764ce331316efc0ae3c2ea754d3d8ce20 100644 (file)
@@ -1073,8 +1073,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;
         }
 
@@ -4979,8 +4978,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 ||
@@ -5048,8 +5046,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 ||