[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH v1 06/25] error: Add error_printf_fn()
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [RFC PATCH v1 06/25] error: Add error_printf_fn() |
Date: |
Fri, 11 Sep 2015 10:10:17 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 09/10/2015 11:33 PM, Peter Crosthwaite wrote:
> Add an API to report an error with a custom printf function. Use
> this for the implementation of error_report_err().
>
> Signed-off-by: Peter Crosthwaite <address@hidden>
> ---
>
> include/qapi/error.h | 7 +++++++
> util/error.c | 22 ++++++++++++++++++++--
> 2 files changed, 27 insertions(+), 2 deletions(-)
Sounds independently useful.
>
> diff --git a/include/qapi/error.h b/include/qapi/error.h
> index b25c72f..0e5c311 100644
> --- a/include/qapi/error.h
> +++ b/include/qapi/error.h
> @@ -94,6 +94,13 @@ const char *error_get_pretty(Error *err);
> void error_report_err(Error *);
>
> /**
> + * Report an and free an error object using a custom printf implementation.
s/an and/and/
> + */
> +
> +void error_printf_fn(Error *err, void (*printf_fn)(void *, const char *,
> ...),
> + void *printf_opaque);
> +
> +/**
> * Propagate an error to an indirect pointer to an error. This function will
> * always transfer ownership of the error reference and handles the case
> where
> * dst_err is NULL correctly. Errors after the first are discarded.
> diff --git a/util/error.c b/util/error.c
> index e9c23ce..c4656af 100644
> --- a/util/error.c
> +void error_printf_fn(Error *err, void (*printf_fn)(void *, const char *,
> ...),
> + void *printf_opaque)
> +{
> + if (err->next) {
> + error_printf_fn(err->next, printf_fn, printf_opaque);
> + }
> + printf_fn(printf_opaque, "%s\n", error_get_pretty(err));
> + error_free(err);
> +}
Of course, if you rebase this to come independent of multi-error, it
won't need the first 'if'. But it looks like a reasonable factorization.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [RFC PATCH v1 02/25] s390x: virtio-ccw: Remove un-needed if guard, (continued)
- [Qemu-devel] [RFC PATCH v1 02/25] s390x: virtio-ccw: Remove un-needed if guard, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 03/25] error: Factor out common error setter logic, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 04/25] error: Add support for multiple errors, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 05/25] error: Add error prefix API, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 07/25] sysbus: mmio_map+mmio_get_region: ignore range OOB errors, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 06/25] error: Add error_printf_fn(), Peter Crosthwaite, 2015/09/11
- Re: [Qemu-devel] [RFC PATCH v1 06/25] error: Add error_printf_fn(),
Eric Blake <=
- [Qemu-devel] [RFC PATCH v1 08/25] memory: nop APIs when they have NULL arguments, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 09/25] qdev: gpio: Ignore unconnectable GPIOs, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 10/25] arm: xlnx-zynqmp: Update error API usages, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 12/25] arm: netduino: Update error API usages, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 11/25] arm: fsl-imx*: Update error API usages, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 13/25] arm: allwinner: Update error API usages, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 14/25] arm: digic: Update error API usages, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 15/25] cpu: arm: Remove un-needed error checking, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 16/25] ppc: Update error API usages, Peter Crosthwaite, 2015/09/11
- [Qemu-devel] [RFC PATCH v1 17/25] i386: pc: Update error API usages, Peter Crosthwaite, 2015/09/11