[PATCH 2/4] virCPUDefFormatBufFull: Use our general error handling pattern

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

 



Well, so far there are no variables to free, no cleanup work needed on
an error, so bare 'return -1;' after each error is just okay. But this
will change in a while.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/cpu_conf.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 4a367a1..9a430ef 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -555,6 +555,8 @@ virCPUDefFormatBufFull(virBufferPtr buf,
                        virCPUDefPtr def,
                        bool updateCPU)
 {
+    int ret = -1;
+
     if (!def)
         return 0;
 
@@ -566,7 +568,7 @@ virCPUDefFormatBufFull(virBufferPtr buf,
             if (!(tmp = virCPUModeTypeToString(def->mode))) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("Unexpected CPU mode %d"), def->mode);
-                return -1;
+                goto cleanup;
             }
             virBufferAsprintf(buf, " mode='%s'", tmp);
         }
@@ -578,7 +580,7 @@ virCPUDefFormatBufFull(virBufferPtr buf,
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("Unexpected CPU match policy %d"),
                                def->match);
-                return -1;
+                goto cleanup;
             }
             virBufferAsprintf(buf, " match='%s'", tmp);
         }
@@ -590,12 +592,14 @@ virCPUDefFormatBufFull(virBufferPtr buf,
         virBufferAsprintf(buf, "<arch>%s</arch>\n",
                           virArchToString(def->arch));
     if (virCPUDefFormatBuf(buf, def, updateCPU) < 0)
-        return -1;
+        goto cleanup;
     virBufferAdjustIndent(buf, -2);
 
     virBufferAddLit(buf, "</cpu>\n");
 
-    return 0;
+    ret = 0;
+ cleanup:
+    return ret;
 }
 
 int
-- 
2.0.5

--
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]