On Thu, Feb 19, 2015 at 02:13:43PM +0100, Michal Privoznik wrote:
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 <[email protected]>
---
src/conf/cpu_conf.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)


ACK, but you could've just squashed it in with the next one, I guess.

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
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: pgpMHPiSNvJLB.pgp
Description: PGP signature

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to