error: Remove unnecessary local_err variables
This patch simplifies code that uses a local_err variable just to immediately use it for an error_propagate() call. Coccinelle patch used to perform the changes added to scripts/coccinelle/remove_local_err.cocci. Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <1465855078-19435-3-git-send-email-ehabkost@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Blank line in s390-virtio-ccw.c restored] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
621ff94d50
commit
6b62d96137
@ -582,12 +582,10 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
Error **errp)
|
||||
{
|
||||
BDRVRawState *s = bs->opaque;
|
||||
Error *local_err = NULL;
|
||||
int ret;
|
||||
|
||||
s->type = FTYPE_FILE;
|
||||
ret = raw_open_common(bs, options, flags, 0, &local_err);
|
||||
error_propagate(errp, local_err);
|
||||
ret = raw_open_common(bs, options, flags, 0, errp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2439,14 +2437,12 @@ static int cdrom_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
Error **errp)
|
||||
{
|
||||
BDRVRawState *s = bs->opaque;
|
||||
Error *local_err = NULL;
|
||||
int ret;
|
||||
|
||||
s->type = FTYPE_CD;
|
||||
|
||||
/* 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);
|
||||
error_propagate(errp, local_err);
|
||||
ret = raw_open_common(bs, options, flags, O_NONBLOCK, errp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -190,11 +190,9 @@ static int raw_has_zero_init(BlockDriverState *bs)
|
||||
|
||||
static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
int ret;
|
||||
|
||||
ret = bdrv_create_file(filename, opts, &local_err);
|
||||
error_propagate(errp, local_err);
|
||||
ret = bdrv_create_file(filename, opts, errp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -180,10 +180,8 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
|
||||
static void s390_hot_add_cpu(const int64_t id, Error **errp)
|
||||
{
|
||||
MachineState *machine = MACHINE(qdev_get_machine());
|
||||
Error *err = NULL;
|
||||
|
||||
s390x_new_cpu(machine->cpu_model, id, &err);
|
||||
error_propagate(errp, err);
|
||||
s390x_new_cpu(machine->cpu_model, id, errp);
|
||||
}
|
||||
|
||||
static void ccw_machine_class_init(ObjectClass *oc, void *data)
|
||||
|
@ -884,13 +884,11 @@ static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||
DeviceState *qdev = DEVICE(ccw_dev);
|
||||
VirtIONetCcw *dev = VIRTIO_NET_CCW(ccw_dev);
|
||||
DeviceState *vdev = DEVICE(&dev->vdev);
|
||||
Error *err = NULL;
|
||||
|
||||
virtio_net_set_netclient_name(&dev->vdev, qdev->id,
|
||||
object_get_typename(OBJECT(qdev)));
|
||||
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
|
||||
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
||||
error_propagate(errp, err);
|
||||
object_property_set_bool(OBJECT(vdev), true, "realized", errp);
|
||||
}
|
||||
|
||||
static void virtio_ccw_net_instance_init(Object *obj)
|
||||
@ -907,11 +905,9 @@ static void virtio_ccw_blk_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||
{
|
||||
VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev);
|
||||
DeviceState *vdev = DEVICE(&dev->vdev);
|
||||
Error *err = NULL;
|
||||
|
||||
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
|
||||
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
||||
error_propagate(errp, err);
|
||||
object_property_set_bool(OBJECT(vdev), true, "realized", errp);
|
||||
}
|
||||
|
||||
static void virtio_ccw_blk_instance_init(Object *obj)
|
||||
@ -931,7 +927,6 @@ static void virtio_ccw_serial_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||
VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(ccw_dev);
|
||||
DeviceState *vdev = DEVICE(&dev->vdev);
|
||||
DeviceState *proxy = DEVICE(ccw_dev);
|
||||
Error *err = NULL;
|
||||
char *bus_name;
|
||||
|
||||
/*
|
||||
@ -945,8 +940,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);
|
||||
error_propagate(errp, err);
|
||||
object_property_set_bool(OBJECT(vdev), true, "realized", errp);
|
||||
}
|
||||
|
||||
|
||||
@ -962,11 +956,9 @@ static void virtio_ccw_balloon_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||
{
|
||||
VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(ccw_dev);
|
||||
DeviceState *vdev = DEVICE(&dev->vdev);
|
||||
Error *err = NULL;
|
||||
|
||||
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
|
||||
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
||||
error_propagate(errp, err);
|
||||
object_property_set_bool(OBJECT(vdev), true, "realized", errp);
|
||||
}
|
||||
|
||||
static void virtio_ccw_balloon_instance_init(Object *obj)
|
||||
@ -987,7 +979,6 @@ static void virtio_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||
VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(ccw_dev);
|
||||
DeviceState *vdev = DEVICE(&dev->vdev);
|
||||
DeviceState *qdev = DEVICE(ccw_dev);
|
||||
Error *err = NULL;
|
||||
char *bus_name;
|
||||
|
||||
/*
|
||||
@ -1001,8 +992,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);
|
||||
error_propagate(errp, err);
|
||||
object_property_set_bool(OBJECT(vdev), true, "realized", errp);
|
||||
}
|
||||
|
||||
static void virtio_ccw_scsi_instance_init(Object *obj)
|
||||
@ -1020,11 +1010,9 @@ static void vhost_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||
{
|
||||
VHostSCSICcw *dev = VHOST_SCSI_CCW(ccw_dev);
|
||||
DeviceState *vdev = DEVICE(&dev->vdev);
|
||||
Error *err = NULL;
|
||||
|
||||
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
|
||||
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
||||
error_propagate(errp, err);
|
||||
object_property_set_bool(OBJECT(vdev), true, "realized", errp);
|
||||
}
|
||||
|
||||
static void vhost_ccw_scsi_instance_init(Object *obj)
|
||||
@ -1842,11 +1830,9 @@ static void virtio_ccw_9p_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||
{
|
||||
V9fsCCWState *dev = VIRTIO_9P_CCW(ccw_dev);
|
||||
DeviceState *vdev = DEVICE(&dev->vdev);
|
||||
Error *err = NULL;
|
||||
|
||||
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
|
||||
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
||||
error_propagate(errp, err);
|
||||
object_property_set_bool(OBJECT(vdev), true, "realized", errp);
|
||||
}
|
||||
|
||||
static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data)
|
||||
|
29
scripts/coccinelle/remove_local_err.cocci
Normal file
29
scripts/coccinelle/remove_local_err.cocci
Normal file
@ -0,0 +1,29 @@
|
||||
// Replace unnecessary usage of local_err variable with
|
||||
// direct usage of errp argument
|
||||
|
||||
@@
|
||||
identifier F;
|
||||
expression list ARGS;
|
||||
expression F2;
|
||||
identifier LOCAL_ERR;
|
||||
identifier ERRP;
|
||||
idexpression V;
|
||||
typedef Error;
|
||||
@@
|
||||
F(..., Error **ERRP)
|
||||
{
|
||||
...
|
||||
- Error *LOCAL_ERR;
|
||||
... when != LOCAL_ERR
|
||||
when != ERRP
|
||||
(
|
||||
- F2(ARGS, &LOCAL_ERR);
|
||||
- error_propagate(ERRP, LOCAL_ERR);
|
||||
+ F2(ARGS, ERRP);
|
||||
|
|
||||
- V = F2(ARGS, &LOCAL_ERR);
|
||||
- error_propagate(ERRP, LOCAL_ERR);
|
||||
+ V = F2(ARGS, ERRP);
|
||||
)
|
||||
... when != LOCAL_ERR
|
||||
}
|
@ -1875,7 +1875,6 @@ static void x86_cpu_get_feature_words(Object *obj, Visitor *v,
|
||||
{
|
||||
uint32_t *array = (uint32_t *)opaque;
|
||||
FeatureWord w;
|
||||
Error *err = NULL;
|
||||
X86CPUFeatureWordInfo word_infos[FEATURE_WORDS] = { };
|
||||
X86CPUFeatureWordInfoList list_entries[FEATURE_WORDS] = { };
|
||||
X86CPUFeatureWordInfoList *list = NULL;
|
||||
@ -1895,8 +1894,7 @@ static void x86_cpu_get_feature_words(Object *obj, Visitor *v,
|
||||
list = &list_entries[w];
|
||||
}
|
||||
|
||||
visit_type_X86CPUFeatureWordInfoList(v, "feature-words", &list, &err);
|
||||
error_propagate(errp, err);
|
||||
visit_type_X86CPUFeatureWordInfoList(v, "feature-words", &list, errp);
|
||||
}
|
||||
|
||||
static void x86_get_hv_spinlocks(Object *obj, Visitor *v, const char *name,
|
||||
|
Loading…
Reference in New Issue
Block a user