util: split out VIR_ALLOC calls

To make the following commits simpler.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Ján Tomko 2020-10-02 19:16:19 +02:00
parent 0a46abaa4f
commit 2566345a5c
2 changed files with 8 additions and 8 deletions

View File

@ -2636,8 +2636,10 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
VIR_FORCE_CLOSE(cmd->infd);
/* clear any error so we can catch if the helper thread reports one */
cmd->has_error = 0;
if (VIR_ALLOC(cmd->asyncioThread) < 0 ||
virThreadCreateFull(cmd->asyncioThread, true,
if (VIR_ALLOC(cmd->asyncioThread) < 0)
ret = -1;
if (virThreadCreateFull(cmd->asyncioThread, true,
virCommandDoAsyncIOHelper,
"cmd-async-io", false, cmd) < 0) {
virReportSystemError(errno, "%s",

View File

@ -672,12 +672,10 @@ virXPathNodeSet(const char *xpath,
ret = obj->nodesetval->nodeNr;
if (list != NULL && ret) {
if (VIR_ALLOC_N(*list, ret) < 0) {
ret = -1;
} else {
memcpy(*list, obj->nodesetval->nodeTab,
ret * sizeof(xmlNodePtr));
}
if (VIR_ALLOC_N(*list, ret) < 0)
return -1;
memcpy(*list, obj->nodesetval->nodeTab, ret * sizeof(xmlNodePtr));
}
xmlXPathFreeObject(obj);
return ret;