[sheepdog] [RFC v5 024/126] error: auto propagated local_err
Eric Blake
eblake at redhat.com
Fri Nov 8 23:45:12 CET 2019
On 11/8/19 3:10 PM, Marc-André Lureau wrote:
>> +/*
>> + * ERRP_AUTO_PROPAGATE
>> + *
>> + * This macro is created to be the first line of a function with Error **errp
>> + * OUT parameter. It's needed only in cases where we want to use error_prepend,
>> + * error_append_hint or dereference *errp. It's still safe (but useless) in
>> + * other cases.
>> + *
>> + * If errp is NULL or points to error_fatal, it is rewritten to point to a
>> + * local Error object, which will be automatically propagated to the original
>> + * errp on function exit (see error_propagator_cleanup).
>> + *
>> + * After invocation of this macro it is always safe to dereference errp
>> + * (as it's not NULL anymore) and to add information (by error_prepend or
>> + * error_append_hint)
>> + * (as, if it was error_fatal, we swapped it with a local_error to be
>> + * propagated on cleanup).
>
> Nice improvements. Minor drawback, the abort()/exit() will now take
> place when going out of scope and running the cleanup instead of error
> location. Not a big problem I guess.
Your assessment is not quite right:
Any abort() will happen at the leaf node (because we are no longer
wrapping thing into a local err and skipping error_propagate altogether
for &error_abort).
You are correct that any exit() will now happen during cleanup, but that
is an undetectable change (there is no stack trace present for
&error_fatal, so calling error_propagate at a later point in time does
not affect the observable end behavior).
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
More information about the sheepdog
mailing list