Eric Blake <ebl...@redhat.com> writes: > 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.
I'm changing the reference to 007b06578ab anyway. >> 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. We can track down the recipe when the manual cleanup becomes tiresome. >> >> Cc: David Gibson <da...@gibson.dropbear.id.au> >> Cc: Alexander Graf <ag...@suse.de> >> Cc: Eric Blake <ebl...@redhat.com> >> Cc: Paolo Bonzini <pbonz...@redhat.com> >> Signed-off-by: Markus Armbruster <arm...@redhat.com> >> --- >> 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. Yes. >> +- error_report_err(ERR); >> +- exit(EC); >> +- } > > Reviewed-by: Eric Blake <ebl...@redhat.com> Thanks!