[GEDI] [RFC v2 2/9] qapi/error: add (Error **errp) cleaning APIs

Eric Blake eblake at redhat.com
Mon Sep 23 18:39:13 UTC 2019


On 9/23/19 11:12 AM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov at virtuozzo.com>
> ---

A "why" as the commit message body wouldn't hurt.

>  include/qapi/error.h | 22 ++++++++++++++++++++++
>  util/error.c         |  6 +++---
>  2 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/include/qapi/error.h b/include/qapi/error.h
> index f6f4fa0fac..551385aa91 100644
> --- a/include/qapi/error.h
> +++ b/include/qapi/error.h
> @@ -297,6 +297,28 @@ void warn_report_err(Error *err);
>   */
>  void error_report_err(Error *err);
>  
> +/*
> + * Functions to clean Error **errp: call corresponding Error *err cleaning
> + * function an set pointer to NULL

s/an/and/

> + */
> +static inline void error_free_errp(Error **errp)
> +{
> +    error_free(*errp_in);

Fails to compile.  Did you mean for this to come after 3/9?

> +    *errp_in = NULL;
> +}
> +
> +static inline void error_report_errp(Error **errp)
> +{
> +    error_report_err(*errp_in);
> +    *errp_in = NULL;
> +}
> +
> +static inline void warn_report_errp(Error **errp)
> +{
> +    warn_report_err(*errp_in);
> +    *errp_in = NULL;
> +}
> +
>  /*
>   * Convenience function to error_prepend(), warn_report() and free @err.
>   */
> diff --git a/util/error.c b/util/error.c
> index d4532ce318..dfba091757 100644
> --- a/util/error.c
> +++ b/util/error.c
> @@ -273,9 +273,9 @@ void error_free(Error *err)
>  
>  void error_free_or_abort(Error **errp)
>  {
> -    assert(errp && *errp);
> -    error_free(*errp);
> -    *errp = NULL;
> +    assert(errp_in && *errp_in);
> +    error_free(*errp_in);
> +    *errp_in = NULL;

Did you mean to use error_free_errp() instead of these last two lines?

>  }
>  
>  void error_propagate(Error **dst_errp, Error *local_err)
> 

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


More information about the integration mailing list