qemu-block
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]