[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v2 2/9] qapi/error: add (Error **errp) cleaning APIs
From: |
Eric Blake |
Subject: |
Re: [RFC v2 2/9] qapi/error: add (Error **errp) cleaning APIs |
Date: |
Mon, 23 Sep 2019 13:39:13 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
On 9/23/19 11:12 AM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
> ---
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
- [RFC v2 0/9] error: auto propagated local_err, Vladimir Sementsov-Ogievskiy, 2019/09/23
- [RFC v2 5/9] net/net: fix local variable shadowing in net_client_init, Vladimir Sementsov-Ogievskiy, 2019/09/23
- [RFC v2 7/9] Use auto-propagated errp, Vladimir Sementsov-Ogievskiy, 2019/09/23
- [RFC v2 2/9] qapi/error: add (Error **errp) cleaning APIs, Vladimir Sementsov-Ogievskiy, 2019/09/23
- Re: [RFC v2 2/9] qapi/error: add (Error **errp) cleaning APIs,
Eric Blake <=
- [RFC v2 1/9] error: auto propagated local_err, Vladimir Sementsov-Ogievskiy, 2019/09/23
- [RFC v2 3/9] errp: rename errp to errp_in where it is IN-argument, Vladimir Sementsov-Ogievskiy, 2019/09/23
- [RFC v2 9/9] fix-compilation: includes, Vladimir Sementsov-Ogievskiy, 2019/09/23
- [RFC v2 8/9] fix-compilation: empty goto, Vladimir Sementsov-Ogievskiy, 2019/09/23
- [RFC v2 6/9] scripts: add coccinelle script to use auto propagated errp, Vladimir Sementsov-Ogievskiy, 2019/09/23