mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
storage: Fix return value checks for virAsprintf
Use the < 0 rather than == -1 (consistently) for virAsprintf errors. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
55b1f1aaba
commit
d062dfd9d9
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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 ||
|
||||
|
Loading…
Reference in New Issue
Block a user