[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: |
Markus Armbruster |
Subject: |
Re: [PATCH v3 06/44] qemu-option: Check return value instead of @err where convenient |
Date: |
Mon, 06 Jul 2020 22:01:38 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Greg Kurz <groug@kaod.org> writes:
> 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.
Yes, and that's actually why I do it. I'll change the commit message to
say so:
to
opts = qemu_opts_create(..., 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 :)
Yes, error_propagate() becomes a no-op for one out of three error paths
through it. There's similar "partial no-opification" elsewhere in this
series, notably in PATCH 36.
Concrete suggestions for improving the commit message further are
welcome!
>> 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;
> }
Don't fit my clarified commit message, because I can't replace &err by
errp there.
I found these:
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 7194bc7f06..471b597dfe 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -294,17 +294,13 @@ static int read_config(BDRVBlkdebugState *s, const char
*filename,
d.s = s;
d.action = ACTION_INJECT_ERROR;
- qemu_opts_foreach(&inject_error_opts, add_rule, &d, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (qemu_opts_foreach(&inject_error_opts, add_rule, &d, errp)) {
ret = -EINVAL;
goto fail;
}
d.action = ACTION_SET_STATE;
- qemu_opts_foreach(&set_state_opts, add_rule, &d, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (qemu_opts_foreach(&set_state_opts, add_rule, &d, errp)) {
ret = -EINVAL;
goto fail;
}
However, I really need to get a pull request out... Can patch them
later.
> With or without the extra changes:
>
> Reviewed-by: Greg Kurz <groug@kaod.org>
Thanks!
- Re: [PATCH v3 24/44] qom: Use return values to check for error where that's simpler, (continued)
- [PATCH v3 02/44] error: Document Error API usage rules, Markus Armbruster, 2020/07/06
- [PATCH v3 15/44] hmp: Eliminate a variable in hmp_migrate_set_parameter(), Markus Armbruster, 2020/07/06
- [PATCH v3 08/44] qemu-option: Factor out helper find_default_by_name(), Markus Armbruster, 2020/07/06
- [PATCH v3 22/44] qom: Crash more nicely on object_property_get_link() failure, Markus Armbruster, 2020/07/06
- [PATCH v3 21/44] qom: Rename qdev_get_type() to object_get_type(), Markus Armbruster, 2020/07/06
- [PATCH v3 10/44] qemu-option: Factor out helper opt_create(), Markus Armbruster, 2020/07/06
- [PATCH v3 06/44] qemu-option: Check return value instead of @err where convenient, Markus Armbruster, 2020/07/06
- [PATCH v3 03/44] qdev: Use returned bool to check for qdev_realize() etc. failure, Markus Armbruster, 2020/07/06
[PATCH v3 18/44] qapi: Use returned bool to check for failure, manual part, Markus Armbruster, 2020/07/06
[PATCH v3 30/44] qdev: Make functions taking Error ** return bool, not void, Markus Armbruster, 2020/07/06
[PATCH v3 13/44] qemu-option: Use returned bool to check for failure, Markus Armbruster, 2020/07/06
[PATCH v3 17/44] qapi: Use returned bool to check for failure, Coccinelle part, Markus Armbruster, 2020/07/06