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 <vsement...@virtuozzo.com>
> ---

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 <ebl...@redhat.com>

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

Reply via email to