mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +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);
|
VIR_FREE(vol->target.path);
|
||||||
if (virAsprintf(&vol->target.path, "%s/%s",
|
if (virAsprintf(&vol->target.path, "%s/%s",
|
||||||
pool->def->target.path,
|
pool->def->target.path,
|
||||||
vol->name) == -1)
|
vol->name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
cmd = virCommandNewArgList(LVCREATE,
|
cmd = virCommandNewArgList(LVCREATE,
|
||||||
|
@ -404,13 +404,13 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
|
|||||||
VIR_FREE(vol->target.path);
|
VIR_FREE(vol->target.path);
|
||||||
if (virAsprintf(&vol->target.path, "%s/%s",
|
if (virAsprintf(&vol->target.path, "%s/%s",
|
||||||
pool->def->source.name,
|
pool->def->source.name,
|
||||||
vol->name) == -1)
|
vol->name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
VIR_FREE(vol->key);
|
VIR_FREE(vol->key);
|
||||||
if (virAsprintf(&vol->key, "%s/%s",
|
if (virAsprintf(&vol->key, "%s/%s",
|
||||||
pool->def->source.name,
|
pool->def->source.name,
|
||||||
vol->name) == -1)
|
vol->name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -662,13 +662,13 @@ virStorageBackendRBDCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
VIR_FREE(vol->target.path);
|
VIR_FREE(vol->target.path);
|
||||||
if (virAsprintf(&vol->target.path, "%s/%s",
|
if (virAsprintf(&vol->target.path, "%s/%s",
|
||||||
pool->def->source.name,
|
pool->def->source.name,
|
||||||
vol->name) == -1)
|
vol->name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
VIR_FREE(vol->key);
|
VIR_FREE(vol->key);
|
||||||
if (virAsprintf(&vol->key, "%s/%s",
|
if (virAsprintf(&vol->key, "%s/%s",
|
||||||
pool->def->source.name,
|
pool->def->source.name,
|
||||||
vol->name) == -1)
|
vol->name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -249,7 +249,7 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
VIR_FREE(vol->key);
|
VIR_FREE(vol->key);
|
||||||
if (virAsprintf(&vol->key, "%s/%s",
|
if (virAsprintf(&vol->key, "%s/%s",
|
||||||
pool->def->source.name, vol->name) == -1)
|
pool->def->source.name, vol->name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
VIR_FREE(vol->target.path);
|
VIR_FREE(vol->target.path);
|
||||||
@ -374,7 +374,7 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
VIR_FREE(vol->key);
|
VIR_FREE(vol->key);
|
||||||
if (virAsprintf(&vol->key, "%s/%s",
|
if (virAsprintf(&vol->key, "%s/%s",
|
||||||
pool->def->source.name, vol->name) == -1)
|
pool->def->source.name, vol->name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
VIR_FREE(vol->target.path);
|
VIR_FREE(vol->target.path);
|
||||||
|
@ -89,7 +89,7 @@ virStorageBackendZFSCheckPool(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
|
|||||||
char *devpath;
|
char *devpath;
|
||||||
|
|
||||||
if (virAsprintf(&devpath, "/dev/zvol/%s",
|
if (virAsprintf(&devpath, "/dev/zvol/%s",
|
||||||
pool->def->source.name) == -1)
|
pool->def->source.name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
*isActive = virFileIsDir(devpath);
|
*isActive = virFileIsDir(devpath);
|
||||||
VIR_FREE(devpath);
|
VIR_FREE(devpath);
|
||||||
@ -322,7 +322,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
VIR_FREE(vol->target.path);
|
VIR_FREE(vol->target.path);
|
||||||
if (virAsprintf(&vol->target.path, "%s/%s",
|
if (virAsprintf(&vol->target.path, "%s/%s",
|
||||||
pool->def->target.path, vol->name) == -1)
|
pool->def->target.path, vol->name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (VIR_STRDUP(vol->key, vol->target.path) < 0)
|
if (VIR_STRDUP(vol->key, vol->target.path) < 0)
|
||||||
|
@ -1982,7 +1982,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
|
|||||||
while ((direrr = virDirRead(dh, &dent, NULL)) > 0) {
|
while ((direrr = virDirRead(dh, &dent, NULL)) > 0) {
|
||||||
if (virAsprintf(&stablepath, "%s/%s",
|
if (virAsprintf(&stablepath, "%s/%s",
|
||||||
pool->def->target.path,
|
pool->def->target.path,
|
||||||
dent->d_name) == -1) {
|
dent->d_name) < 0) {
|
||||||
VIR_DIR_CLOSE(dh);
|
VIR_DIR_CLOSE(dh);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2082,7 +2082,7 @@ virStorageBackendVolCreateLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
VIR_FREE(vol->target.path);
|
VIR_FREE(vol->target.path);
|
||||||
if (virAsprintf(&vol->target.path, "%s/%s",
|
if (virAsprintf(&vol->target.path, "%s/%s",
|
||||||
pool->def->target.path,
|
pool->def->target.path,
|
||||||
vol->name) == -1)
|
vol->name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virFileExists(vol->target.path)) {
|
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 */
|
vol->target.format = VIR_STORAGE_FILE_RAW; /* Real value is filled in during probe */
|
||||||
if (virAsprintf(&vol->target.path, "%s/%s",
|
if (virAsprintf(&vol->target.path, "%s/%s",
|
||||||
pool->def->target.path,
|
pool->def->target.path,
|
||||||
vol->name) == -1)
|
vol->name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_STRDUP(vol->key, vol->target.path) < 0)
|
if (VIR_STRDUP(vol->key, vol->target.path) < 0)
|
||||||
|
@ -1073,8 +1073,7 @@ testOpenVolumesForPool(const char *file,
|
|||||||
|
|
||||||
if (def->target.path == NULL) {
|
if (def->target.path == NULL) {
|
||||||
if (virAsprintf(&def->target.path, "%s/%s",
|
if (virAsprintf(&def->target.path, "%s/%s",
|
||||||
obj->def->target.path,
|
obj->def->target.path, def->name) < 0)
|
||||||
def->name) == -1)
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4979,8 +4978,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virAsprintf(&privvol->target.path, "%s/%s",
|
if (virAsprintf(&privvol->target.path, "%s/%s",
|
||||||
obj->def->target.path,
|
obj->def->target.path, privvol->name) < 0)
|
||||||
privvol->name) == -1)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 ||
|
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);
|
obj->def->available = (obj->def->capacity - obj->def->allocation);
|
||||||
|
|
||||||
if (virAsprintf(&privvol->target.path, "%s/%s",
|
if (virAsprintf(&privvol->target.path, "%s/%s",
|
||||||
obj->def->target.path,
|
obj->def->target.path, privvol->name) < 0)
|
||||||
privvol->name) == -1)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 ||
|
if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 ||
|
||||||
|
Loading…
Reference in New Issue
Block a user