[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 35/44] error: Eliminate error_propagate() with Coccinelle,
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v2 35/44] error: Eliminate error_propagate() with Coccinelle, part 2 |
Date: |
Fri, 03 Jul 2020 08:59:32 +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. The previous commit did that with a Coccinelle script I
>> consider fairly trustworthy. This commit uses the same script with
>> the matching of return taken out, i.e. we convert
>>
>> if (!foo(..., &err)) {
>> ...
>> error_propagate(errp, err);
>> ...
>> }
>>
>> to
>>
>> if (!foo(..., errp)) {
>> ...
>> ...
>> }
>>
>> This is unsound: @err could still be read between afterwards. I don't
>> know how to express "no read of @err without an intervening write" in
>> Coccinelle. Instead, I manually double-checked for uses of @err.
>>
>> Suboptimal line breaks tweaked manually. qdev_realize() simplified
>> further to placate scripts/checkpatch.pl.
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>> block.c | 6 ++----
>> block/blkdebug.c | 7 ++-----
>> block/blklogwrites.c | 3 +--
>> block/blkverify.c | 3 +--
>> block/crypto.c | 4 +---
>> block/file-posix.c | 6 ++----
>> block/file-win32.c | 6 ++----
>> block/gluster.c | 4 +---
>> block/iscsi.c | 3 +--
>> block/nbd.c | 8 ++------
>> block/qcow2.c | 13 ++++---------
>> block/raw-format.c | 4 +---
>> block/sheepdog.c | 8 ++------
>> block/ssh.c | 4 +---
>> block/throttle.c | 4 +---
>> block/vmdk.c | 4 +---
>> block/vpc.c | 3 +--
>> block/vvfat.c | 3 +--
>> blockdev.c | 3 +--
>> hw/intc/xics.c | 4 +---
>> hw/vfio/pci.c | 3 +--
>> net/tap.c | 3 +--
>> qom/object.c | 4 +---
>> 23 files changed, 32 insertions(+), 78 deletions(-)
>
> Small enough to review each instance.
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
I tried *really* hard to make part 1's script powerful and safe, to give
the unsafe / manual parts (this commit and next) a chance of meaningful
review. Thanks for providing it!
- Re: [PATCH v2 28/44] qom: Use returned bool to check for failure, Coccinelle part, (continued)
- Re: [PATCH v2 00/44] Less clumsy error checking, Markus Armbruster, 2020/07/02
- [PATCH v2 39/44] qapi: Smooth visitor error checking in generated code, Markus Armbruster, 2020/07/02
- [PATCH v2 40/44] qapi: Purge error_propagate() from QAPI core, Markus Armbruster, 2020/07/02
- [PATCH v2 35/44] error: Eliminate error_propagate() with Coccinelle, part 2, Markus Armbruster, 2020/07/02
- [PATCH v2 38/44] qapi: Smooth another visitor error checking pattern, Markus Armbruster, 2020/07/02
- Re: [PATCH v2 00/44] Less clumsy error checking, no-reply, 2020/07/02
- Re: [PATCH v2 00/44] Less clumsy error checking, no-reply, 2020/07/02