qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 06/44] qemu-option: Check return value instead of @err whe


From: Greg Kurz
Subject: Re: [PATCH v3 06/44] qemu-option: Check return value instead of @err where convenient
Date: Mon, 6 Jul 2020 17:59:17 +0200

On Mon,  6 Jul 2020 10:09:12 +0200
Markus Armbruster <armbru@redhat.com> wrote:

> Convert uses like
> 
>     opts = qemu_opts_create(..., &err);
>     if (err) {
>         ...
>     }
> 
> to
> 
>     opts = qemu_opts_create(..., &err);

The patch doesn't strictly do that since it also converts &err to errp.
This is okay because most of the changes also drop the associated
error_propagate(), with the exception of block/parallels.c for which
I had to check how local_err is used. As already noted by Vladimir
earlier this generates an harmless "no-op error_propagate", but it
could be worth mentioning that in the changelog for future reviews :)

>     if (!opts) {
>         ...
>     }
> 
> Eliminate error_propagate() that are now unnecessary.  Delete @err
> that are now unused.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/parallels.c  |  4 ++--
>  blockdev.c         |  5 ++---
>  qdev-monitor.c     |  5 ++---
>  util/qemu-config.c | 10 ++++------
>  util/qemu-option.c | 12 ++++--------

Maybe some other potential candidates ?

chardev/char.c:

   opts = qemu_opts_create(qemu_find_opts("chardev"), label, 1, &local_err);
    if (local_err) {
        error_report_err(local_err);
        return NULL;
    }

monitor/hmp-cmds.c:

    opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &err);
    if (err) {
        goto out;
    }


    opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err);
    if (err) {
        goto end;
    }

With or without the extra changes:

Reviewed-by: Greg Kurz <groug@kaod.org>

>  5 files changed, 14 insertions(+), 22 deletions(-)
> 
> diff --git a/block/parallels.c b/block/parallels.c
> index 63a1cde8af..f26f03c926 100644
> --- a/block/parallels.c
> +++ b/block/parallels.c
> @@ -824,8 +824,8 @@ static int parallels_open(BlockDriverState *bs, QDict 
> *options, int flags,
>          }
>      }
>  
> -    opts = qemu_opts_create(&parallels_runtime_opts, NULL, 0, &local_err);
> -    if (local_err != NULL) {
> +    opts = qemu_opts_create(&parallels_runtime_opts, NULL, 0, errp);
> +    if (!opts) {
>          goto fail_options;
>      }
>  
> diff --git a/blockdev.c b/blockdev.c
> index 31d5eaf6bf..b52ed9de86 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -504,9 +504,8 @@ static BlockBackend *blockdev_init(const char *file, 
> QDict *bs_opts,
>      /* Check common options by copying from bs_opts to opts, all other 
> options
>       * stay in bs_opts for processing by bdrv_open(). */
>      id = qdict_get_try_str(bs_opts, "id");
> -    opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error);
> -    if (error) {
> -        error_propagate(errp, error);
> +    opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, errp);
> +    if (!opts) {
>          goto err_no_opts;
>      }
>  
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index 13a13a811a..079cb6001e 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -799,9 +799,8 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, 
> Error **errp)
>      QemuOpts *opts;
>      DeviceState *dev;
>  
> -    opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, errp);
> +    if (!opts) {
>          return;
>      }
>      if (!monitor_cur_is_qmp() && qdev_device_help(opts)) {
> diff --git a/util/qemu-config.c b/util/qemu-config.c
> index 772f5a219e..c0d0e9b8ef 100644
> --- a/util/qemu-config.c
> +++ b/util/qemu-config.c
> @@ -493,9 +493,8 @@ static void config_parse_qdict_section(QDict *options, 
> QemuOptsList *opts,
>          goto out;
>      }
>  
> -    subopts = qemu_opts_create(opts, NULL, 0, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    subopts = qemu_opts_create(opts, NULL, 0, errp);
> +    if (!subopts) {
>          goto out;
>      }
>  
> @@ -538,10 +537,9 @@ static void config_parse_qdict_section(QDict *options, 
> QemuOptsList *opts,
>              }
>  
>              opt_name = g_strdup_printf("%s.%u", opts->name, i++);
> -            subopts = qemu_opts_create(opts, opt_name, 1, &local_err);
> +            subopts = qemu_opts_create(opts, opt_name, 1, errp);
>              g_free(opt_name);
> -            if (local_err) {
> -                error_propagate(errp, local_err);
> +            if (!subopts) {
>                  goto out;
>              }
>  
> diff --git a/util/qemu-option.c b/util/qemu-option.c
> index 0ebfd97a98..fd1fd23521 100644
> --- a/util/qemu-option.c
> +++ b/util/qemu-option.c
> @@ -670,11 +670,9 @@ void qemu_opts_set(QemuOptsList *list, const char *id,
>                     const char *name, const char *value, Error **errp)
>  {
>      QemuOpts *opts;
> -    Error *local_err = NULL;
>  
> -    opts = qemu_opts_create(list, id, 1, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    opts = qemu_opts_create(list, id, 1, errp);
> +    if (!opts) {
>          return;
>      }
>      qemu_opt_set(opts, name, value, errp);
> @@ -1012,10 +1010,8 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, 
> const QDict *qdict,
>      QemuOpts *opts;
>      const QDictEntry *entry;
>  
> -    opts = qemu_opts_create(list, qdict_get_try_str(qdict, "id"), 1,
> -                            &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    opts = qemu_opts_create(list, qdict_get_try_str(qdict, "id"), 1, errp);
> +    if (!opts) {
>          return NULL;
>      }
>  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]