From d062dfd9d9a4705bf274c902de90df43325f81f4 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Mon, 8 May 2017 07:30:19 -0400 Subject: [PATCH] storage: Fix return value checks for virAsprintf Use the < 0 rather than == -1 (consistently) for virAsprintf errors. Signed-off-by: John Ferlan --- 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 ed26c24509..67f70e5517 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 c806d6d304..7b8887b930 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 a9a2301e63..b55d96a7e2 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 004d95a538..c6dae7183d 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 493c651b7f..e1fe162ed9 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)) { @@ -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) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 45e9adc8ba..0fefa89764 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -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 || -- GitLab