mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
parallels: Resolve issues with uninitialized 'ret' value
Added some messaging to indicate possible failure from virXPathULongLong() as well
This commit is contained in:
parent
71da3b66a8
commit
bbf1806f31
@ -258,7 +258,7 @@ static int parallelsDiskDescParseNode(xmlDocPtr xml,
|
|||||||
virStorageVolDefPtr def)
|
virStorageVolDefPtr def)
|
||||||
{
|
{
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
int ret;
|
int ret = -1;
|
||||||
|
|
||||||
if (STRNEQ((const char *)root->name, "Parallels_disk_image")) {
|
if (STRNEQ((const char *)root->name, "Parallels_disk_image")) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
@ -275,11 +275,16 @@ static int parallelsDiskDescParseNode(xmlDocPtr xml,
|
|||||||
ctxt->node = root;
|
ctxt->node = root;
|
||||||
|
|
||||||
if (virXPathULongLong("string(./Disk_Parameters/Disk_size)",
|
if (virXPathULongLong("string(./Disk_Parameters/Disk_size)",
|
||||||
ctxt, &def->capacity))
|
ctxt, &def->capacity) < 0) {
|
||||||
ret = -1;
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
"%s", _("failed to get disk size from "
|
||||||
|
"the disk descriptor xml"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
def->capacity <<= 9;
|
def->capacity <<= 9;
|
||||||
def->allocation = def->capacity;
|
def->allocation = def->capacity;
|
||||||
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
xmlXPathFreeContext(ctxt);
|
xmlXPathFreeContext(ctxt);
|
||||||
return ret;
|
return ret;
|
||||||
@ -315,7 +320,8 @@ static int parallelsAddDiskVolume(virStoragePoolObjPtr pool,
|
|||||||
|
|
||||||
def->type = VIR_STORAGE_VOL_FILE;
|
def->type = VIR_STORAGE_VOL_FILE;
|
||||||
|
|
||||||
parallelsDiskDescParse(diskDescPath, def);
|
if (parallelsDiskDescParse(diskDescPath, def) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (!(def->target.path = realpath(diskPath, NULL)))
|
if (!(def->target.path = realpath(diskPath, NULL)))
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
@ -330,8 +336,9 @@ static int parallelsAddDiskVolume(virStoragePoolObjPtr pool,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
no_memory:
|
no_memory:
|
||||||
virStorageVolDefFree(def);
|
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
|
error:
|
||||||
|
virStorageVolDefFree(def);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user