On Fri, 10 Jan 2020 22:41:48 +0300 Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> > --- > Reviewed-by: Greg Kurz <gr...@kaod.org> > CC: Cornelia Huck <coh...@redhat.com> > CC: Eric Blake <ebl...@redhat.com> > CC: Kevin Wolf <kw...@redhat.com> > CC: Max Reitz <mre...@redhat.com> > CC: Greg Kurz <gr...@kaod.org> > CC: Stefan Hajnoczi <stefa...@redhat.com> > CC: Stefano Stabellini <sstabell...@kernel.org> > CC: Anthony Perard <anthony.per...@citrix.com> > CC: Paul Durrant <p...@xen.org> > CC: "Philippe Mathieu-Daudé" <phi...@redhat.com> > CC: Laszlo Ersek <ler...@redhat.com> > CC: Gerd Hoffmann <kra...@redhat.com> > CC: Stefan Berger <stef...@linux.ibm.com> > CC: Markus Armbruster <arm...@redhat.com> > CC: Michael Roth <mdr...@linux.vnet.ibm.com> > CC: qemu-bl...@nongnu.org > CC: xen-de...@lists.xenproject.org > > include/qapi/error.h | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/include/qapi/error.h b/include/qapi/error.h > index ad5b6e896d..fa8d51fd6d 100644 > --- a/include/qapi/error.h > +++ b/include/qapi/error.h > @@ -309,6 +309,32 @@ void warn_reportf_err(Error *err, const char *fmt, ...) > void error_reportf_err(Error *err, const char *fmt, ...) > GCC_FMT_ATTR(2, 3); > > +/* > + * Functions to clean Error **errp: call corresponding Error *err cleaning > + * function an set pointer to NULL > + */ > +static inline void error_free_errp(Error **errp) > +{ > + assert(errp && *errp); > + error_free(*errp); > + *errp = NULL; > +} > + > +static inline void error_report_errp(Error **errp) > +{ > + assert(errp && *errp); > + error_report_err(*errp); > + *errp = NULL; > +} > + > +static inline void warn_report_errp(Error **errp) > +{ > + assert(errp && *errp); > + warn_report_err(*errp); > + *errp = NULL; > +} > + > + > /* > * Just like error_setg(), except you get to specify the error class. > * Note: use of error classes other than ERROR_CLASS_GENERIC_ERROR is