提交 4f380977 编写于 作者: W Wang Huaqiang 提交者: Michal Privoznik

conf: some code cleanup

Creating object and judging if it is successfully created in fewer
lines.
Signed-off-by: NWang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 48e188d2
......@@ -19389,8 +19389,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
return -1;
if (!alloc) {
alloc = virResctrlAllocNew();
if (!alloc)
if (!(alloc = virResctrlAllocNew()))
return -1;
} else {
virReportError(VIR_ERR_XML_ERROR, "%s",
......@@ -19403,8 +19402,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
return -1;
}
resctrl = virDomainResctrlNew(node, alloc, vcpus, flags);
if (!resctrl)
if (!(resctrl = virDomainResctrlNew(node, alloc, vcpus, flags)))
return -1;
if (virDomainResctrlMonDefParse(def, ctxt, node,
......@@ -19593,8 +19591,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
return -1;
if (!alloc) {
alloc = virResctrlAllocNew();
if (!alloc)
if (!(alloc = virResctrlAllocNew()))
return -1;
new_alloc = true;
}
......@@ -19612,8 +19609,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
* just update the existing alloc information, which is done in above
* virDomainMemorytuneDefParseMemory */
if (new_alloc) {
resctrl = virDomainResctrlNew(node, alloc, vcpus, flags);
if (!resctrl)
if (!(resctrl = virDomainResctrlNew(node, alloc, vcpus, flags)))
return -1;
if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册