]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virCPUDefFormatBufFull: Use our general error handling pattern
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 18 Feb 2015 17:06:44 +0000 (18:06 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 25 Feb 2015 08:23:45 +0000 (09:23 +0100)
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@redhat.com>
src/conf/cpu_conf.c

index 4e33934698501f96203f07bf2d7d9c1e92226cf5..2bce525d5113dd541ddf2a2c52a5e493059dc695 100644 (file)
@@ -434,6 +434,8 @@ virCPUDefFormatBufFull(virBufferPtr buf,
                        virDomainNumaPtr numa,
                        bool updateCPU)
 {
+    int ret = -1;
+
     if (!def)
         return 0;
 
@@ -445,7 +447,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);
         }
@@ -457,7 +459,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);
         }
@@ -469,15 +471,17 @@ virCPUDefFormatBufFull(virBufferPtr buf,
         virBufferAsprintf(buf, "<arch>%s</arch>\n",
                           virArchToString(def->arch));
     if (virCPUDefFormatBuf(buf, def, updateCPU) < 0)
-        return -1;
+        goto cleanup;
 
     if (virDomainNumaDefCPUFormat(buf, numa) < 0)
-        return -1;
+        goto cleanup;
 
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</cpu>\n");
 
-    return 0;
+    ret = 0;
+ cleanup:
+    return ret;
 }
 
 int