mirror of https://gitee.com/openkylin/libvirt.git
tests: check and handle error for virAsprintf() calls
This commit is contained in:
parent
0c6e95fe78
commit
7ac12d84d0
|
@ -179,7 +179,9 @@ testParseVMXFileName(const char *fileName, void *opaque ATTRIBUTE_UNUSED)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
virAsprintf(&src, "[%s] %s", datastoreName, directoryAndFileName);
|
||||
if (virAsprintf(&src, "[%s] %s", datastoreName,
|
||||
directoryAndFileName) < 0)
|
||||
goto cleanup;
|
||||
} else if (STRPREFIX(fileName, "/")) {
|
||||
/* Found absolute path referencing a file outside a datastore */
|
||||
src = strdup(fileName);
|
||||
|
@ -188,7 +190,8 @@ testParseVMXFileName(const char *fileName, void *opaque ATTRIBUTE_UNUSED)
|
|||
src = NULL;
|
||||
} else {
|
||||
/* Found single file name referencing a file inside a datastore */
|
||||
virAsprintf(&src, "[datastore] directory/%s", fileName);
|
||||
if (virAsprintf(&src, "[datastore] directory/%s", fileName) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
|
|
@ -193,8 +193,9 @@ testFormatVMXFileName(const char *src, void *opaque ATTRIBUTE_UNUSED)
|
|||
directoryAndFileName += strspn(directoryAndFileName, " ");
|
||||
}
|
||||
|
||||
virAsprintf(&absolutePath, "/vmfs/volumes/%s/%s", datastoreName,
|
||||
directoryAndFileName);
|
||||
if (virAsprintf(&absolutePath, "/vmfs/volumes/%s/%s", datastoreName,
|
||||
directoryAndFileName) < 0)
|
||||
goto cleanup;
|
||||
} else if (STRPREFIX(src, "/")) {
|
||||
/* Found absolute path */
|
||||
absolutePath = strdup(src);
|
||||
|
|
Loading…
Reference in New Issue