Patchwork [V17,9/9] qemu-option: use qemu_opts_del without judging NULL

login
register
mail settings
Submitter Robert Wang
Date July 17, 2013, 9:29 a.m.
Message ID <1374053388-17431-10-git-send-email-wdongxu@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/259646/
State New
Headers show

Comments

Robert Wang - July 17, 2013, 9:29 a.m.
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
---
 block.c        | 8 ++------
 hw/core/qdev.c | 4 +---
 qemu-char.c    | 4 +---
 qemu-img.c     | 4 +---
 4 files changed, 5 insertions(+), 15 deletions(-)

Patch

diff --git a/block.c b/block.c
index e1d1c3d..e700593 100644
--- a/block.c
+++ b/block.c
@@ -408,9 +408,7 @@  int bdrv_create(BlockDriver *drv, const char* filename, QemuOpts *opts)
     ret = cco.ret;
 
 out:
-    if (!opts) {
-        qemu_opts_del(cco.opts);
-    }
+    qemu_opts_del(cco.opts);
     g_free(cco.filename);
     return ret;
 }
@@ -4575,9 +4573,7 @@  void bdrv_img_create(const char *filename, const char *fmt,
     }
 
 out:
-    if (opts) {
-        qemu_opts_del(opts);
-    }
+    qemu_opts_del(opts);
     qemu_opts_free(create_opts);
 
     if (bs) {
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 9190a7e..2a33eca 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -768,9 +768,7 @@  static void device_initfn(Object *obj)
 static void device_finalize(Object *obj)
 {
     DeviceState *dev = DEVICE(obj);
-    if (dev->opts) {
-        qemu_opts_del(dev->opts);
-    }
+    qemu_opts_del(dev->opts);
 }
 
 static void device_class_base_init(ObjectClass *class, void *data)
diff --git a/qemu-char.c b/qemu-char.c
index 800d6a6..6cd650d 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3379,9 +3379,7 @@  void qemu_chr_delete(CharDriverState *chr)
     }
     g_free(chr->filename);
     g_free(chr->label);
-    if (chr->opts) {
-        qemu_opts_del(chr->opts);
-    }
+    qemu_opts_del(chr->opts);
     g_free(chr);
 }
 
diff --git a/qemu-img.c b/qemu-img.c
index 3f1b6ee..44dd07d 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1527,9 +1527,7 @@  static int img_convert(int argc, char **argv)
 out:
     qemu_progress_end();
     qemu_opts_free(create_opts);
-    if (opts) {
-        qemu_opts_del(opts);
-    }
+    qemu_opts_del(opts);
     qemu_vfree(buf);
     if (out_bs) {
         bdrv_delete(out_bs);