[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 34/44] error: Eliminate error_propagate() with Coccinelle,
From: |
Eric Blake |
Subject: |
Re: [PATCH v2 34/44] error: Eliminate error_propagate() with Coccinelle, part 1 |
Date: |
Thu, 2 Jul 2020 13:02:13 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
On 7/2/20 10:49 AM, Markus Armbruster wrote:
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
Not exactly elegant, I'm afraid.
True, but it is still reasonable enough to use.
The "when != goto lbl;" is necessary to avoid transforming
spelled "when != lbl:" above in rule1 and rule2
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently fails to convert hw/arm/armsse.c, because Coccinelle gets
confused by ARMSSE being used both as typedef and function-like macro
there. Converted manually.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
114 files changed, 376 insertions(+), 884 deletions(-)
Big, but sane. Picks up the spots I noticed in 33/44, and then some ;)
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
- Re: [PATCH v2 14/44] block: Avoid error accumulation in bdrv_img_create(), (continued)
- [PATCH v2 23/44] qom: Crash more nicely on object_property_get_link() failure, Markus Armbruster, 2020/07/02
- [PATCH v2 32/44] qdev: Use returned bool to check for failure, Coccinelle part, Markus Armbruster, 2020/07/02
- [PATCH v2 34/44] error: Eliminate error_propagate() with Coccinelle, part 1, Markus Armbruster, 2020/07/02
- Re: [PATCH v2 34/44] error: Eliminate error_propagate() with Coccinelle, part 1,
Eric Blake <=
- [PATCH v2 26/44] qom: Put name parameter before value / visitor parameter, Markus Armbruster, 2020/07/02
- [PATCH v2 15/44] hmp: Eliminate a variable in hmp_migrate_set_parameter(), Markus Armbruster, 2020/07/02
- [PATCH v2 06/44] qemu-option: Check return value instead of @err where convenient, Markus Armbruster, 2020/07/02
- [PATCH v2 22/44] qom: Rename qdev_get_type() to object_get_type(), Markus Armbruster, 2020/07/02