[PATCHv2 04/11] conf: some code cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Wang Huaqiang <huaqiang.wang@xxxxxxxxx>
---
 src/conf/domain_conf.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index db25c1f..e4a6dfb 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19336,8 +19336,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
         return -1;
 
     if (!alloc) {
-        alloc = virResctrlAllocNew();
-        if (!alloc)
+        if (!(alloc = virResctrlAllocNew()))
             return -1;
     } else {
         virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -19350,8 +19349,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,
@@ -19540,8 +19538,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
         return -1;
 
     if (!alloc) {
-        alloc = virResctrlAllocNew();
-        if (!alloc)
+        if (!(alloc = virResctrlAllocNew()))
             return -1;
         new_alloc = true;
     }
@@ -19559,8 +19556,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)
-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux