提交 7ac12d84 编写于 作者: J John Ferlan 提交者: Eric Blake

tests: check and handle error for virAsprintf() calls

上级 0c6e95fe
...@@ -179,7 +179,9 @@ testParseVMXFileName(const char *fileName, void *opaque ATTRIBUTE_UNUSED) ...@@ -179,7 +179,9 @@ testParseVMXFileName(const char *fileName, void *opaque ATTRIBUTE_UNUSED)
goto cleanup; goto cleanup;
} }
virAsprintf(&src, "[%s] %s", datastoreName, directoryAndFileName); if (virAsprintf(&src, "[%s] %s", datastoreName,
directoryAndFileName) < 0)
goto cleanup;
} else if (STRPREFIX(fileName, "/")) { } else if (STRPREFIX(fileName, "/")) {
/* Found absolute path referencing a file outside a datastore */ /* Found absolute path referencing a file outside a datastore */
src = strdup(fileName); src = strdup(fileName);
...@@ -188,7 +190,8 @@ testParseVMXFileName(const char *fileName, void *opaque ATTRIBUTE_UNUSED) ...@@ -188,7 +190,8 @@ testParseVMXFileName(const char *fileName, void *opaque ATTRIBUTE_UNUSED)
src = NULL; src = NULL;
} else { } else {
/* Found single file name referencing a file inside a datastore */ /* 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: cleanup:
......
...@@ -193,8 +193,9 @@ testFormatVMXFileName(const char *src, void *opaque ATTRIBUTE_UNUSED) ...@@ -193,8 +193,9 @@ testFormatVMXFileName(const char *src, void *opaque ATTRIBUTE_UNUSED)
directoryAndFileName += strspn(directoryAndFileName, " "); directoryAndFileName += strspn(directoryAndFileName, " ");
} }
virAsprintf(&absolutePath, "/vmfs/volumes/%s/%s", datastoreName, if (virAsprintf(&absolutePath, "/vmfs/volumes/%s/%s", datastoreName,
directoryAndFileName); directoryAndFileName) < 0)
goto cleanup;
} else if (STRPREFIX(src, "/")) { } else if (STRPREFIX(src, "/")) {
/* Found absolute path */ /* Found absolute path */
absolutePath = strdup(src); absolutePath = strdup(src);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册