From: Wang Huaqiang Date: Tue, 11 Jun 2019 03:31:09 +0000 (+0800) Subject: conf: some code cleanup X-Git-Tag: v5.7.0-rc1~407 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f380977fe6f0f7fa3a4a81087ca1cae9b5067fa;p=thirdparty%2Flibvirt.git conf: some code cleanup Creating object and judging if it is successfully created in fewer lines. Signed-off-by: Wang Huaqiang Reviewed-by: Michal Privoznik --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 72e8757a84..08df300b59 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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)