conf: some code cleanup

Creating object and judging if it is successfully created in fewer
lines.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Wang Huaqiang 2019-06-11 11:31:09 +08:00 committed by Michal Privoznik
parent 48e188d2a8
commit 4f380977fe

View File

@ -19389,8 +19389,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
return -1; return -1;
if (!alloc) { if (!alloc) {
alloc = virResctrlAllocNew(); if (!(alloc = virResctrlAllocNew()))
if (!alloc)
return -1; return -1;
} else { } else {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
@ -19403,8 +19402,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
return -1; return -1;
} }
resctrl = virDomainResctrlNew(node, alloc, vcpus, flags); if (!(resctrl = virDomainResctrlNew(node, alloc, vcpus, flags)))
if (!resctrl)
return -1; return -1;
if (virDomainResctrlMonDefParse(def, ctxt, node, if (virDomainResctrlMonDefParse(def, ctxt, node,
@ -19593,8 +19591,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
return -1; return -1;
if (!alloc) { if (!alloc) {
alloc = virResctrlAllocNew(); if (!(alloc = virResctrlAllocNew()))
if (!alloc)
return -1; return -1;
new_alloc = true; new_alloc = true;
} }
@ -19612,8 +19609,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
* just update the existing alloc information, which is done in above * just update the existing alloc information, which is done in above
* virDomainMemorytuneDefParseMemory */ * virDomainMemorytuneDefParseMemory */
if (new_alloc) { if (new_alloc) {
resctrl = virDomainResctrlNew(node, alloc, vcpus, flags); if (!(resctrl = virDomainResctrlNew(node, alloc, vcpus, flags)))
if (!resctrl)
return -1; return -1;
if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0) if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0)