qemu-option: Use returned bool to check for failure
commit235e59cf03ed75d0ce96c97343194ed11c146231
authorMarkus Armbruster <armbru@redhat.com>
Tue, 7 Jul 2020 16:05:42 +0000 (7 18:05 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 10 Jul 2020 13:17:35 +0000 (10 15:17 +0200)
treec2de9b6a66355d038fe4ccb4d79de13905101b52
parentc75d7f71918b8497a710f3f2b646567c09db3770
qemu-option: Use returned bool to check for failure

The previous commit enables conversion of

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

to

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

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

    @@
    identifier fun = {
        opts_do_parse, parse_option_bool, parse_option_number,
        parse_option_size, qemu_opt_parse, qemu_opt_rename, qemu_opt_set,
        qemu_opt_set_bool, qemu_opt_set_number, qemu_opts_absorb_qdict,
        qemu_opts_do_parse, qemu_opts_from_qdict_entry, qemu_opts_set,
        qemu_opts_validate
    };
    expression list args, args2;
    typedef Error;
    Error *err;
    @@
    -    fun(args, &err, args2);
    -    if (err)
    +    if (!fun(args, &err, args2))
         {
             ...
         }

A few 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-15-armbru@redhat.com>
[Conflict with commit 0b6786a9c1 "block/amend: refactor qcow2 amend
options" resolved by rerunning Coccinelle on master's version]
32 files changed:
block.c
block/blkdebug.c
block/blklogwrites.c
block/blkverify.c
block/crypto.c
block/curl.c
block/file-posix.c
block/file-win32.c
block/gluster.c
block/iscsi.c
block/nbd.c
block/parallels.c
block/qcow2.c
block/quorum.c
block/raw-format.c
block/replication.c
block/sheepdog.c
block/ssh.c
block/throttle.c
block/vpc.c
block/vvfat.c
block/vxhs.c
blockdev.c
chardev/char.c
contrib/ivshmem-server/main.c
hw/net/virtio-net.c
hw/smbios/smbios.c
qapi/string-input-visitor.c
qemu-img.c
tpm.c
util/qemu-config.c
util/qemu-option.c