Patchwork [08/10] vmdk: share cleanup code

login
register
mail settings
Submitter Juan Quintela
Date March 4, 2010, 9 a.m.
Message ID <11eb03941aaf0d5f0160279371ca33352a981387.1267692963.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/46897/
State New
Headers show

Comments

Juan Quintela - March 4, 2010, 9 a.m.
cleanup code is identical for error/success cases.  Only difference
are goto labels.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 block/vmdk.c |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)

Patch

diff --git a/block/vmdk.c b/block/vmdk.c
index 819c1c9..007fca4 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -334,18 +334,13 @@  static int vmdk_snapshot_create(const char *filename, const char *backing_file)
         ret = -errno;
         goto fail_gd;
     }
-    qemu_free(gd_buf);
-    qemu_free(rgd_buf);
-
-    close(p_fd);
-    close(snp_fd);
-    return 0;
+    ret = 0;

-    fail_gd:
+fail_gd:
     qemu_free(gd_buf);
-    fail_rgd:
+fail_rgd:
     qemu_free(rgd_buf);
-    fail:
+fail:
     close(p_fd);
     close(snp_fd);
     return ret;