qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 01/31] Use error_fatal to simplify obvious fatal


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 01/31] Use error_fatal to simplify obvious fatal errors (again)
Date: Mon, 8 Oct 2018 15:32:56 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0

On 10/8/18 12:30 PM, Markus Armbruster wrote:
Add a slight improvement of the Coccinelle semantic patch from commit
07d04a0219b,

which shares the same commit title, but does not actually have a semantic patch, but rather defers to the even older 007b065. But I'm not too worried about either the duplicated commit title nor the chain of references to follow - as this is a no-semantic-change patch rather than a bugfix, it's less likely to cause confusion to any downstream backport efforts.

and use it to clean up.  It leaves dead Error * variables
behind, cleaned up manually.

Coccinelle can handle that too, if we want to make the .cocci file longer (but off-hand, I don't remember the exact semantic patch formula to express a variable that is initialized but then never used, as a result of applying earlier semantic patches). So the manual cleanup for now still seems tractable.


Cc: David Gibson <address@hidden>
Cc: Alexander Graf <address@hidden>
Cc: Eric Blake <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
---
  hw/intc/xics_kvm.c                       |  7 +------
  qemu-nbd.c                               |  6 +-----
  scripts/coccinelle/use-error_fatal.cocci | 20 ++++++++++++++++++++
  vl.c                                     |  7 +------
  4 files changed, 23 insertions(+), 17 deletions(-)
  create mode 100644 scripts/coccinelle/use-error_fatal.cocci


+++ b/scripts/coccinelle/use-error_fatal.cocci
@@ -0,0 +1,20 @@
+@@
+type T;
+identifier FUN, RET;
+expression list ARGS;
+expression ERR, EC, FAIL;

The slight improvement from the original git commit log script is the addition of FAIL,

+@@
+(
+-    T RET = FUN(ARGS, &ERR);
++    T RET = FUN(ARGS, &error_fatal);
+|
+-    RET = FUN(ARGS, &ERR);
++    RET = FUN(ARGS, &error_fatal);
+|
+-    FUN(ARGS, &ERR);
++    FUN(ARGS, &error_fatal);
+)
+-    if (FAIL) {

and a check for arbitrary condition FAIL rather than a more specific ERR != NULL. Makes sense.

+-        error_report_err(ERR);
+-        exit(EC);
+-    }

Reviewed-by: Eric Blake <address@hidden>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



reply via email to

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