[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 05/25] scripts: add coccinelle script to fix error_append_
From: |
Eric Blake |
Subject: |
Re: [PATCH v3 05/25] scripts: add coccinelle script to fix error_append_hint usage |
Date: |
Tue, 24 Sep 2019 15:48:48 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
On 9/24/19 3:08 PM, Vladimir Sementsov-Ogievskiy wrote:
> error_append_hint will not work, if errp == &fatal_error, as program
> will exit before error_append_hint call. Fix this by use of special
> macro ERRP_FUNCTION_BEGIN.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
> ---
With the approach of a partial cleanup (rather than globally enforcing
it for all functions with errp parameter), we'll probably be rerunning
this Coccinelle script regularly, to track down any regressions.
> +++ b/scripts/coccinelle/fix-error_append_hint-usage.cocci
> @@ -0,0 +1,25 @@
> +@rule0@
> +// Add invocation to errp-functions
> +identifier fn;
> +@@
> +
> + fn(..., Error **errp, ...)
> + {
> ++ ERRP_FUNCTION_BEGIN();
> + <+...
> + error_append_hint(errp, ...);
> + ...+>
> + }
Does not catch the case that we want to also use the macro for any use
of *errp, but we can augment that later.
> +
> +@@
> +// Drop doubled invocation
> +identifier rule0.fn;
> +@@
> +
> + fn(...)
> +{
> + ERRP_FUNCTION_BEGIN();
> +- ERRP_FUNCTION_BEGIN();
> + ...
> +}
This is smaller than the script you posted in v2, and thus I'm a bit
more confident in stating that it looks correct and idempotent.
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
Re: [PATCH v3 00/25] error: auto propagated local_err, no-reply, 2019/09/25