[PATCH] conf: Make full use of goto lable

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

 



* virDomainDefParse: There is a goto label "no_memory", which
reports OOM error, and it then fallthrough lable "error". This
patch changes things like following:

    virReportOOMError();
    goto error;

into:

    goto no_memory;
---
 src/conf/domain_conf.c |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5360863..f80ab43 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5832,8 +5832,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         char *set = tmp;
         def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN;
         if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) {
-            virReportOOMError();
-            goto error;
+            goto no_memory;
         }
         if (virDomainCpuSetParse((const char **)&set,
                                  0, def->cpumask,
@@ -5894,8 +5893,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
             int nodemasklen = VIR_DOMAIN_CPUMASK_LEN;
 
             if (VIR_ALLOC_N(def->numatune.memory.nodemask, nodemasklen) < 0) {
-                virReportOOMError();
-                goto error;
+                goto no_memory;
             }
 
             /* "nodeset" leads same syntax with "cpuset". */
@@ -6010,8 +6008,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         if (def->os.bootloader) {
             def->os.type = strdup("xen");
             if (!def->os.type) {
-                virReportOOMError();
-                goto error;
+                goto no_memory;
             }
         } else {
             virDomainReportError(VIR_ERR_OS_TYPE,
@@ -6028,8 +6025,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         def->virtType == VIR_DOMAIN_VIRT_XEN) {
         VIR_FREE(def->os.type);
         if (!(def->os.type = strdup("xen"))) {
-            virReportOOMError();
-            goto error;
+            goto no_memory;
         }
     }
 
@@ -6056,8 +6052,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
             goto error;
         }
         if (!(def->os.arch = strdup(defaultArch))) {
-            virReportOOMError();
-            goto error;
+            goto no_memory;
         }
     }
 
@@ -6069,8 +6064,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
                                                                         virDomainVirtTypeToString(def->virtType));
         if (defaultMachine != NULL) {
             if (!(def->os.machine = strdup(defaultMachine))) {
-                virReportOOMError();
-                goto error;
+                goto no_memory;
             }
         }
     }
@@ -6403,8 +6397,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         virDomainInputDefPtr input;
 
         if (VIR_ALLOC(input) < 0) {
-            virReportOOMError();
-            goto error;
+            goto no_memory;
         }
         if (STREQ(def->os.type, "hvm")) {
             input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
-- 
1.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]