qemu-option: Check return value instead of @err where convenient

Convert uses like

    opts = qemu_opts_create(..., &err);
    if (err) {
        ...
    }

to

    opts = qemu_opts_create(..., errp);
    if (!opts) {
        ...
    }

Eliminate error_propagate() that are now unnecessary.  Delete @err
that are now unused.

Note that we can't drop parallels_open()'s error_propagate() here.  We
continue to execute it even in the converted case.  It's a no-op then:
local_err is null.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <20200707160613.848843-8-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2020-07-07 18:05:35 +02:00
parent 79c3e2bc6e
commit c6ecec43b2
5 changed files with 14 additions and 22 deletions

View File

@ -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); opts = qemu_opts_create(&parallels_runtime_opts, NULL, 0, errp);
if (local_err != NULL) { if (!opts) {
goto fail_options; goto fail_options;
} }

View File

@ -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 /* Check common options by copying from bs_opts to opts, all other options
* stay in bs_opts for processing by bdrv_open(). */ * stay in bs_opts for processing by bdrv_open(). */
id = qdict_get_try_str(bs_opts, "id"); id = qdict_get_try_str(bs_opts, "id");
opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error); opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, errp);
if (error) { if (!opts) {
error_propagate(errp, error);
goto err_no_opts; goto err_no_opts;
} }

View File

@ -802,9 +802,8 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp)
QemuOpts *opts; QemuOpts *opts;
DeviceState *dev; DeviceState *dev;
opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &local_err); opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, errp);
if (local_err) { if (!opts) {
error_propagate(errp, local_err);
return; return;
} }
if (!monitor_cur_is_qmp() && qdev_device_help(opts)) { if (!monitor_cur_is_qmp() && qdev_device_help(opts)) {

View File

@ -493,9 +493,8 @@ static void config_parse_qdict_section(QDict *options, QemuOptsList *opts,
goto out; goto out;
} }
subopts = qemu_opts_create(opts, NULL, 0, &local_err); subopts = qemu_opts_create(opts, NULL, 0, errp);
if (local_err) { if (!subopts) {
error_propagate(errp, local_err);
goto out; 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++); 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); g_free(opt_name);
if (local_err) { if (!subopts) {
error_propagate(errp, local_err);
goto out; goto out;
} }

View File

@ -670,11 +670,9 @@ void qemu_opts_set(QemuOptsList *list, const char *id,
const char *name, const char *value, Error **errp) const char *name, const char *value, Error **errp)
{ {
QemuOpts *opts; QemuOpts *opts;
Error *local_err = NULL;
opts = qemu_opts_create(list, id, 1, &local_err); opts = qemu_opts_create(list, id, 1, errp);
if (local_err) { if (!opts) {
error_propagate(errp, local_err);
return; return;
} }
qemu_opt_set(opts, name, value, errp); qemu_opt_set(opts, name, value, errp);
@ -1012,10 +1010,8 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
QemuOpts *opts; QemuOpts *opts;
const QDictEntry *entry; const QDictEntry *entry;
opts = qemu_opts_create(list, qdict_get_try_str(qdict, "id"), 1, opts = qemu_opts_create(list, qdict_get_try_str(qdict, "id"), 1, errp);
&local_err); if (!opts) {
if (local_err) {
error_propagate(errp, local_err);
return NULL; return NULL;
} }