[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V4 04/10] introduce qemu_opts_create_nofail func
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH V4 04/10] introduce qemu_opts_create_nofail function |
Date: |
Thu, 25 Oct 2012 14:06:06 +0100 |
On 25 October 2012 13:57, Dong Xu Wang <address@hidden> wrote:
> While id is NULL, qemu_opts_create can not fail, so ignore
> errors is fine.
>
> Signed-off-by: Dong Xu Wang <address@hidden>
> ---
> qemu-option.c | 5 +++++
> qemu-option.h | 1 +
> 2 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/qemu-option.c b/qemu-option.c
> index e0131ce..d7d5ea9 100644
> --- a/qemu-option.c
> +++ b/qemu-option.c
> @@ -780,6 +780,11 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const
> char *id,
> return opts;
> }
>
> +QemuOpts *qemu_opts_create_nofail(QemuOptsList *list)
> +{
> + return qemu_opts_create(list, NULL, 0, NULL);
> +}
_nofail versions of routines generally abort() if the function
they are wrapping returns an error (compare qemu_ram_addr_from_host_nofail
or qdev_init_nofail). This code just ignores the error. Although
as you say at the moment there is nothing that sets an error
in the id==NULL case this is somewhat vulnerable to future code
changes in the function it calls.
I think this would be better as:
{
QemuOpts *opts;
Error *errp = NULL;
opts = qemu_opts_create(list, NULL, 0, &errp);
assert_no_error(errp);
return opts;
}
-- PMM
- [Qemu-devel] [PATCH V4 00/10] replace QEMUOptionParameter with QemuOpts parser, Dong Xu Wang, 2012/10/25
- [Qemu-devel] [PATCH V4 01/10] qemu-option: opt_set(): split it up into more functions, Dong Xu Wang, 2012/10/25
- [Qemu-devel] [PATCH V4 02/10] qemu-option: qemu_opts_validate(): fix duplicated code, Dong Xu Wang, 2012/10/25
- [Qemu-devel] [PATCH V4 06/10] create new function: qemu_opt_set_number, Dong Xu Wang, 2012/10/25
- [Qemu-devel] [PATCH V4 05/10] use qemu_opts_create_nofail, Dong Xu Wang, 2012/10/25
- [Qemu-devel] [PATCH V4 04/10] introduce qemu_opts_create_nofail function, Dong Xu Wang, 2012/10/25
- Re: [Qemu-devel] [PATCH V4 04/10] introduce qemu_opts_create_nofail function,
Peter Maydell <=
- [Qemu-devel] [PATCH V4 03/10] qemu-option: qemu_opt_set_bool(): fix code duplication, Dong Xu Wang, 2012/10/25
- [Qemu-devel] [PATCH V4 07/10] add def_value and use it in qemu_opts_print., Dong Xu Wang, 2012/10/25
- [Qemu-devel] [PATCH V4 08/10] Create four opts list related functions, Dong Xu Wang, 2012/10/25
- [Qemu-devel] [PATCH V4 10/10] remove QEMUOptionParameter related functions and struct, Dong Xu Wang, 2012/10/25
- [Qemu-devel] [PATCH V4 09/10] Use QemuOpts support in block layer, Dong Xu Wang, 2012/10/25