From: Michael Tokarev <mjt@tls.msk.ru>
To: Markus Armbruster <armbru@redhat.com>, Kevin Wolf <kwolf@redhat.com>
Cc: famz@redhat.com, Chen Gang <gang.chen.5i5j@gmail.com>,
qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
mreitz@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH trivial v2] block.c: Add return value for bdrv_append_temp_snapshot() to avoid incorrect failure processing issue
Date: Tue, 24 Jun 2014 20:00:34 +0400 [thread overview]
Message-ID: <53A9A0A2.9010904@msgid.tls.msk.ru> (raw)
In-Reply-To: <87d2dywoyn.fsf@blackfin.pond.sub.org>
24.06.2014 15:01, Markus Armbruster wrote:
> Kevin Wolf <kwolf@redhat.com> writes:
>
>> Am 23.06.2014 um 17:28 hat Chen Gang geschrieben:
>>> When failure occurs, 'ret' need be set, or may return 0 to indicate success.
>>> And error_propagate() also need be called only one time within a function.
>>>
>>> It is abnormal to prevent bdrv_append_temp_snapshot() return value but still
>>> set errp when error occurs -- although it contents return value internally.
>>>
>>> So let bdrv_append_temp_snapshot() internal return value outside, and let
>>> all things normal, then fix the issue too.
>>>
>>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>>
>> What does this fix?
>
> It fixes the return value of bdrv_open() when
> bdrv_append_temp_snapshot() fails. Before this patch, it returns a
> positive value, which is wrong. After the patch, it returns the
> negative error code bdrv_append_temp_snapshot() now returns.
So, what should be done there? Kevin, maybe you should pick this up
instead of going -trivial route?
>> Having both a return value and an Error* object is duplication and
>> only a sign that a function hasn't been fully converted to the Error
>> framework yet. We shouldn't introduce new instances of this without a
>> very good reason.
>
> Maybe. But I very much prefer
>
> ret = foo(arg, errp);
> if (ret < 0) {
> return ret;
> }
>
> over
>
> Error *local_err = NULL;
>
> foo(arg, &local_err);
> if (local_err) {
> error_propagate(errp, local_err);
> return;
> }
Yes, this new error propagation is a bit ugly, I dislike it too.
Thanks,
/mjt
WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: Markus Armbruster <armbru@redhat.com>, Kevin Wolf <kwolf@redhat.com>
Cc: famz@redhat.com, Chen Gang <gang.chen.5i5j@gmail.com>,
qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
mreitz@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH trivial v2] block.c: Add return value for bdrv_append_temp_snapshot() to avoid incorrect failure processing issue
Date: Tue, 24 Jun 2014 20:00:34 +0400 [thread overview]
Message-ID: <53A9A0A2.9010904@msgid.tls.msk.ru> (raw)
In-Reply-To: <87d2dywoyn.fsf@blackfin.pond.sub.org>
24.06.2014 15:01, Markus Armbruster wrote:
> Kevin Wolf <kwolf@redhat.com> writes:
>
>> Am 23.06.2014 um 17:28 hat Chen Gang geschrieben:
>>> When failure occurs, 'ret' need be set, or may return 0 to indicate success.
>>> And error_propagate() also need be called only one time within a function.
>>>
>>> It is abnormal to prevent bdrv_append_temp_snapshot() return value but still
>>> set errp when error occurs -- although it contents return value internally.
>>>
>>> So let bdrv_append_temp_snapshot() internal return value outside, and let
>>> all things normal, then fix the issue too.
>>>
>>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>>
>> What does this fix?
>
> It fixes the return value of bdrv_open() when
> bdrv_append_temp_snapshot() fails. Before this patch, it returns a
> positive value, which is wrong. After the patch, it returns the
> negative error code bdrv_append_temp_snapshot() now returns.
So, what should be done there? Kevin, maybe you should pick this up
instead of going -trivial route?
>> Having both a return value and an Error* object is duplication and
>> only a sign that a function hasn't been fully converted to the Error
>> framework yet. We shouldn't introduce new instances of this without a
>> very good reason.
>
> Maybe. But I very much prefer
>
> ret = foo(arg, errp);
> if (ret < 0) {
> return ret;
> }
>
> over
>
> Error *local_err = NULL;
>
> foo(arg, &local_err);
> if (local_err) {
> error_propagate(errp, local_err);
> return;
> }
Yes, this new error propagation is a bit ugly, I dislike it too.
Thanks,
/mjt
next prev parent reply other threads:[~2014-06-24 16:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-23 15:28 [Qemu-trivial] [PATCH trivial v2] block.c: Add return value for bdrv_append_temp_snapshot() to avoid incorrect failure processing issue Chen Gang
2014-06-23 15:28 ` [Qemu-devel] " Chen Gang
2014-06-24 2:25 ` [Qemu-trivial] " Fam Zheng
2014-06-24 2:25 ` [Qemu-devel] " Fam Zheng
2014-06-24 2:32 ` [Qemu-trivial] " Chen Gang
2014-06-24 2:32 ` [Qemu-devel] " Chen Gang
2014-06-24 10:46 ` [Qemu-trivial] " Kevin Wolf
2014-06-24 10:46 ` [Qemu-devel] " Kevin Wolf
2014-06-24 11:01 ` [Qemu-trivial] " Markus Armbruster
2014-06-24 11:01 ` Markus Armbruster
2014-06-24 16:00 ` Michael Tokarev [this message]
2014-06-24 16:00 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-06-25 22:13 ` [Qemu-trivial] [Qemu-devel] " Chen Gang
2014-06-25 22:13 ` [Qemu-devel] [Qemu-trivial] " Chen Gang
2014-06-27 11:50 ` [Qemu-trivial] [Qemu-devel] " Stefan Hajnoczi
2014-06-27 11:50 ` Stefan Hajnoczi
2014-06-27 17:21 ` [Qemu-trivial] " Kevin Wolf
2014-06-27 17:21 ` [Qemu-devel] " Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53A9A0A2.9010904@msgid.tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=armbru@redhat.com \
--cc=famz@redhat.com \
--cc=gang.chen.5i5j@gmail.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.