On 10/11/19 11:05 AM, Vladimir Sementsov-Ogievskiy wrote:
If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call). Fix such cases.
If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
&error_fatel, this means that we don't break error_abort
(we'll abort on error_set, not on error_propagate)
Reported-by: Kevin Wolf <kw...@redhat.com>
Reported-by: Greg Kurz <gr...@kaod.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>
---
include/block/nbd.h | 1 +
block/nbd.c | 49 +++++++++++++++++++++------------------------
nbd/client.c | 5 +++++
nbd/server.c | 5 +++++
4 files changed, 34 insertions(+), 26 deletions(-)
One of the few patches with a net gain rather than loss of lines, but
that's because of lots of error_prepend use (where you add the macro
without removing error_propagate).
Reviewed-by: Eric Blake <ebl...@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org