mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 23:55:23 +00:00
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:
parent
48e188d2a8
commit
4f380977fe
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user