[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 34/44] error: Eliminate error_propagate() with Coccinelle,
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v2 34/44] error: Eliminate error_propagate() with Coccinelle, part 1 |
Date: |
Fri, 03 Jul 2020 08:55:52 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Eric Blake <eblake@redhat.com> writes:
> 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
Perils of editing old explanations to fit new code...
>>
>> 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 ;)
Right :)
> Reviewed-by: Eric Blake <eblake@redhat.com>
Thanks!
- 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
- [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
- [PATCH v2 31/44] qdev: Make functions taking Error ** return bool, not void, Markus Armbruster, 2020/07/02