Patchwork [08/13] qemu-img: introduce qemu_img_handle_error

login
register
mail settings
Submitter Pavel Hrdina
Date Jan. 9, 2013, 3:18 p.m.
Message ID <2339a816c783bbb2e80335b59adcd1f55b0b7a38.1357741229.git.phrdina@redhat.com>
Download mbox | patch
Permalink /patch/210747/
State New
Headers show

Comments

Pavel Hrdina - Jan. 9, 2013, 3:18 p.m.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 qemu-img.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Patch

diff --git a/qemu-img.c b/qemu-img.c
index 5d667ae..c283bf6 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -292,6 +292,14 @@  static int add_old_style_options(const char *fmt, QEMUOptionParameter *list,
     return 0;
 }
 
+static void qemu_img_handle_error(Error *err)
+{
+    if (error_is_set(&err)) {
+        error_report("%s", error_get_pretty(err));
+        error_free(err);
+    }
+}
+
 static int img_create(int argc, char **argv)
 {
     int c;
@@ -367,8 +375,7 @@  static int img_create(int argc, char **argv)
     bdrv_img_create(filename, fmt, base_filename, base_fmt,
                     options, img_size, BDRV_O_FLAGS, &local_err);
     if (error_is_set(&local_err)) {
-        error_report("%s", error_get_pretty(local_err));
-        error_free(local_err);
+        qemu_img_handle_error(local_err);
         return 1;
     }