]> git.proxmox.com Git - mirror_qemu.git/commit
qom: Use returned bool to check for failure, Coccinelle part
authorMarkus Armbruster <armbru@redhat.com>
Tue, 7 Jul 2020 16:05:56 +0000 (18:05 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 10 Jul 2020 13:18:08 +0000 (15:18 +0200)
commit778a2dc59213d789f5bf8409547b529af4eb9ead
tree5fa10bb05617c2d20de9d7daf5376a85914e3967
parent6fd5bef10b8f0bf64df4e800bfda1da5fe17ca82
qom: Use returned bool to check for failure, Coccinelle part

The previous commit enables conversion of

    foo(..., &err);
    if (err) {
        ...
    }

to

    if (!foo(..., errp)) {
        ...
    }

for QOM functions that now return true / false on success / error.
Coccinelle script:

    @@
    identifier fun = {
        object_apply_global_props, object_initialize_child_with_props,
        object_initialize_child_with_propsv, object_property_get,
        object_property_get_bool, object_property_parse, object_property_set,
        object_property_set_bool, object_property_set_int,
        object_property_set_link, object_property_set_qobject,
        object_property_set_str, object_property_set_uint, object_set_props,
        object_set_propv, user_creatable_add_dict,
        user_creatable_complete, user_creatable_del
    };
    expression list args, args2;
    typedef Error;
    Error *err;
    @@
    -    fun(args, &err, args2);
    -    if (err)
    +    if (!fun(args, &err, args2))
         {
             ...
         }

Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.

Line breaks tidied up manually.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200707160613.848843-29-armbru@redhat.com>
28 files changed:
hw/arm/armsse.c
hw/arm/armv7m.c
hw/arm/aspeed_ast2600.c
hw/arm/aspeed_soc.c
hw/arm/bcm2835_peripherals.c
hw/arm/bcm2836.c
hw/arm/cubieboard.c
hw/arm/digic.c
hw/arm/nrf51_soc.c
hw/arm/stm32f405_soc.c
hw/arm/xlnx-zynqmp.c
hw/block/xen-block.c
hw/core/qdev.c
hw/i386/x86.c
hw/ppc/pnv_psi.c
hw/s390x/s390-pci-bus.c
hw/s390x/s390-virtio-ccw.c
hw/scsi/scsi-bus.c
hw/sd/aspeed_sdhci.c
hw/sd/ssi-sd.c
hw/virtio/virtio-rng.c
qdev-monitor.c
qom/object.c
qom/object_interfaces.c
softmmu/vl.c
target/arm/monitor.c
target/i386/cpu.c
target/s390x/cpu_models.c