summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block.c20
-rw-r--r--block/qcow2.c4
-rw-r--r--block/quorum.c4
-rw-r--r--block/raw-posix.c16
-rw-r--r--block/raw_bsd.c4
-rw-r--r--block/snapshot.c4
-rw-r--r--blockdev.c12
-rw-r--r--bootdevice.c4
-rw-r--r--dump.c4
-rw-r--r--hw/ide/qdev.c4
-rw-r--r--hw/net/ne2000-isa.c4
-rw-r--r--hw/s390x/virtio-ccw.c28
-rw-r--r--hw/usb/dev-storage.c4
-rw-r--r--qga/commands-win32.c8
-rw-r--r--qom/object.c4
-rw-r--r--scripts/coccinelle/error_propagate_null.cocci10
16 files changed, 41 insertions, 93 deletions
diff --git a/block.c b/block.c
index b331eb9d38..524aa542fa 100644
--- a/block.c
+++ b/block.c
@@ -301,9 +301,7 @@ static void coroutine_fn bdrv_create_co_entry(void *opaque)
assert(cco->drv);
ret = cco->drv->bdrv_create(cco->filename, cco->opts, &local_err);
- if (local_err) {
- error_propagate(&cco->err, local_err);
- }
+ error_propagate(&cco->err, local_err);
cco->ret = ret;
}
@@ -364,9 +362,7 @@ int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp)
}
ret = bdrv_create(drv, filename, opts, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
return ret;
}
@@ -1763,18 +1759,14 @@ fail:
QDECREF(options);
bs->options = NULL;
bdrv_unref(bs);
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
return NULL;
close_and_fail:
bdrv_unref(bs);
QDECREF(snapshot_options);
QDECREF(options);
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
return NULL;
}
@@ -3599,9 +3591,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
out:
qemu_opts_del(opts);
qemu_opts_free(create_opts);
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
}
AioContext *bdrv_get_aio_context(BlockDriverState *bs)
diff --git a/block/qcow2.c b/block/qcow2.c
index 4718f8250e..23f666d4ae 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2403,9 +2403,7 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
ret = qcow2_create2(filename, size, backing_file, backing_fmt, flags,
cluster_size, prealloc, opts, version, refcount_order,
&local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
finish:
g_free(backing_file);
diff --git a/block/quorum.c b/block/quorum.c
index ec6f3b9059..331b726f97 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -971,9 +971,7 @@ close_exit:
exit:
qemu_opts_del(opts);
/* propagate error */
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
return ret;
}
diff --git a/block/raw-posix.c b/block/raw-posix.c
index aacf13203f..a825a0a9f5 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -587,9 +587,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
s->type = FTYPE_FILE;
ret = raw_open_common(bs, options, flags, 0, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
return ret;
}
@@ -2236,9 +2234,7 @@ hdev_open_Mac_error:
ret = raw_open_common(bs, options, flags, 0, &local_err);
if (ret < 0) {
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
#if defined(__APPLE__) && defined(__MACH__)
if (*bsd_path) {
filename = bsd_path;
@@ -2450,9 +2446,7 @@ static int cdrom_open(BlockDriverState *bs, QDict *options, int flags,
/* open will not fail even if no CD is inserted, so add O_NONBLOCK */
ret = raw_open_common(bs, options, flags, O_NONBLOCK, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
return ret;
}
@@ -2571,9 +2565,7 @@ static int cdrom_open(BlockDriverState *bs, QDict *options, int flags,
ret = raw_open_common(bs, options, flags, 0, &local_err);
if (ret) {
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
return ret;
}
diff --git a/block/raw_bsd.c b/block/raw_bsd.c
index b1d5237135..5af11b6621 100644
--- a/block/raw_bsd.c
+++ b/block/raw_bsd.c
@@ -194,9 +194,7 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
int ret;
ret = bdrv_create_file(filename, opts, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
return ret;
}
diff --git a/block/snapshot.c b/block/snapshot.c
index da89d2b085..bf5c2ca5e1 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -358,9 +358,7 @@ int bdrv_snapshot_load_tmp_by_id_or_name(BlockDriverState *bs,
ret = bdrv_snapshot_load_tmp(bs, NULL, id_or_name, &local_err);
}
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
return ret;
}
diff --git a/blockdev.c b/blockdev.c
index c9a0068cd6..8f94f760a2 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3644,9 +3644,7 @@ void qmp_drive_mirror(const char *device, const char *target,
has_unmap, unmap,
&local_err);
bdrv_unref(target_bs);
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
out:
aio_context_release(aio_context);
}
@@ -3701,9 +3699,7 @@ void qmp_blockdev_mirror(const char *device, const char *target,
has_on_target_error, on_target_error,
true, true,
&local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
aio_context_release(aio_context);
}
@@ -3913,9 +3909,7 @@ void qmp_change_backing_file(const char *device,
if (ro) {
bdrv_reopen(image_bs, open_flags, &local_err);
- if (local_err) {
- error_propagate(errp, local_err); /* will preserve prior errp */
- }
+ error_propagate(errp, local_err);
}
out:
diff --git a/bootdevice.c b/bootdevice.c
index bb9c08e535..33e3029e40 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -302,9 +302,7 @@ static void device_set_bootindex(Object *obj, Visitor *v, const char *name,
add_boot_device_path(*prop->bootindex, prop->dev, prop->suffix);
out:
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
}
static void property_release_bootindex(Object *obj, const char *name,
diff --git a/dump.c b/dump.c
index 9726f1f477..f7b80d856b 100644
--- a/dump.c
+++ b/dump.c
@@ -918,9 +918,7 @@ static void write_dump_header(DumpState *s, Error **errp)
} else {
create_header64(s, &local_err);
}
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
}
static size_t dump_bitmap_get_bufsize(DumpState *s)
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 4bc74a32d2..6842a5596a 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -233,9 +233,7 @@ static void ide_dev_set_bootindex(Object *obj, Visitor *v, const char *name,
d->unit ? "/disk@1" : "/disk@0");
}
out:
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
}
static void ide_dev_instance_init(Object *obj)
diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c
index a7f5a9464d..8fab7ae2ec 100644
--- a/hw/net/ne2000-isa.c
+++ b/hw/net/ne2000-isa.c
@@ -127,9 +127,7 @@ static void isa_ne2000_set_bootindex(Object *obj, Visitor *v,
s->c.bootindex = boot_index;
out:
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
}
static void isa_ne2000_instance_init(Object *obj)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 2192be8774..348ae4f668 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -890,9 +890,7 @@ static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp)
object_get_typename(OBJECT(qdev)));
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
- if (err) {
- error_propagate(errp, err);
- }
+ error_propagate(errp, err);
}
static void virtio_ccw_net_instance_init(Object *obj)
@@ -913,9 +911,7 @@ static void virtio_ccw_blk_realize(VirtioCcwDevice *ccw_dev, Error **errp)
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
- if (err) {
- error_propagate(errp, err);
- }
+ error_propagate(errp, err);
}
static void virtio_ccw_blk_instance_init(Object *obj)
@@ -950,9 +946,7 @@ static void virtio_ccw_serial_realize(VirtioCcwDevice *ccw_dev, Error **errp)
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
- if (err) {
- error_propagate(errp, err);
- }
+ error_propagate(errp, err);
}
@@ -972,9 +966,7 @@ static void virtio_ccw_balloon_realize(VirtioCcwDevice *ccw_dev, Error **errp)
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
- if (err) {
- error_propagate(errp, err);
- }
+ error_propagate(errp, err);
}
static void virtio_ccw_balloon_instance_init(Object *obj)
@@ -1010,9 +1002,7 @@ static void virtio_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
- if (err) {
- error_propagate(errp, err);
- }
+ error_propagate(errp, err);
}
static void virtio_ccw_scsi_instance_init(Object *obj)
@@ -1034,9 +1024,7 @@ static void vhost_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
- if (err) {
- error_propagate(errp, err);
- }
+ error_propagate(errp, err);
}
static void vhost_ccw_scsi_instance_init(Object *obj)
@@ -1858,9 +1846,7 @@ static void virtio_ccw_9p_realize(VirtioCcwDevice *ccw_dev, Error **errp)
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
- if (err) {
- error_propagate(errp, err);
- }
+ error_propagate(errp, err);
}
static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data)
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 248a580457..9fd00dfffc 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -818,9 +818,7 @@ static void usb_msd_set_bootindex(Object *obj, Visitor *v, const char *name,
}
out:
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
}
static const TypeInfo usb_storage_dev_type_info = {
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index c1a8588206..ea23797c0f 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -247,9 +247,7 @@ out:
if (token) {
CloseHandle(token);
}
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
}
static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque,
@@ -882,9 +880,7 @@ static void check_suspend_mode(GuestSuspendMode mode, Error **errp)
}
out:
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
}
static DWORD WINAPI do_suspend(LPVOID opaque)
diff --git a/qom/object.c b/qom/object.c
index 0311414c0a..9743ea4708 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -549,9 +549,7 @@ Object *object_new_with_propv(const char *typename,
return obj;
error:
- if (local_err) {
- error_propagate(errp, local_err);
- }
+ error_propagate(errp, local_err);
object_unref(obj);
return NULL;
}
diff --git a/scripts/coccinelle/error_propagate_null.cocci b/scripts/coccinelle/error_propagate_null.cocci
new file mode 100644
index 0000000000..c23638007a
--- /dev/null
+++ b/scripts/coccinelle/error_propagate_null.cocci
@@ -0,0 +1,10 @@
+// error_propagate() already ignores local_err==NULL, so there's
+// no need to check it before calling.
+
+@@
+identifier L;
+expression E;
+@@
+-if (L) {
+ error_propagate(E, L);
+-}