From: Eric Blake <eblake@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>,
Markus Armbruster <armbru@redhat.com>
Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org,
mreitz@redhat.com, borntraeger@de.ibm.com,
cornelia.huck@de.ibm.com
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v2 2/3] error: Remove unnecessary local_err variables
Date: Mon, 13 Jun 2016 10:01:16 -0600 [thread overview]
Message-ID: <575ED8CC.6010601@redhat.com> (raw)
In-Reply-To: <20160613155226.GH18662@thinpad.lan.raisama.net>
[-- Attachment #1: Type: text/plain, Size: 1786 bytes --]
On 06/13/2016 09:52 AM, Eduardo Habkost wrote:
>>
>> There is an (ugly) difference between
>>
>> error_setg(&local_err, ...);
>> error_propagate(errp, &local_err);
>>
>> and
>>
>> error_setg(errp, ...);
>>
>> The latter aborts when @errp already contains an error, the former does
>> nothing.
>
> Why the difference? Couldn't we change that so that both are equivalent?
Maybe, but I think it weakens our position. An abort() on an attempt to
incorrectly set an error twice helps catch errors where we are throwing
away a more useful first error message. The documentation for
error_propagate() already mentioned that it was an exception to the rule.
>
>>
>> Your transformation has the error_setg() or similar hidden in F2(). It
>> can add aborts.
>>
>> I think it can be salvaged: we know that @errp must not contain an error
>> on function entry. If @errp doesn't occur elsewhere in this function,
>> it cannot pick up an error on the way to the transformed spot. Can you
>> add that to your when constraints?
>
> Do we really know that *errp is NULL on entry? Aren't we allowed to call
> functions with a non-NULL *errp?
Except for error_propagate(), no.
>
> See, e.g.:
>
> void qmp_guest_suspend_disk(Error **errp)
> {
> Error *local_err = NULL;
> GuestSuspendMode *mode = g_new(GuestSuspendMode, 1);
>
> *mode = GUEST_SUSPEND_MODE_DISK;
> check_suspend_mode(*mode, &local_err);
> acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
> execute_async(do_suspend, mode, &local_err);
That usage is a bug. A Coccinelle script to root out such buggy
instances would be nice.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-06-13 16:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-10 20:12 [Qemu-devel] [PATCH v2 0/3] coccinelle: Clean up error checks and return value variables Eduardo Habkost
2016-06-10 20:12 ` [Qemu-devel] [PATCH v2 1/3] error: Remove NULL checks on error_propagate() calls Eduardo Habkost
2016-06-10 20:54 ` Eric Blake
2016-06-13 7:41 ` Cornelia Huck
2016-06-10 20:12 ` [Qemu-devel] [PATCH v2 2/3] error: Remove unnecessary local_err variables Eduardo Habkost
2016-06-10 20:59 ` Eric Blake
2016-06-10 22:39 ` Eduardo Habkost
2016-06-13 7:44 ` Cornelia Huck
2016-06-13 11:42 ` Markus Armbruster
2016-06-13 15:52 ` Eduardo Habkost
2016-06-13 16:01 ` Eric Blake [this message]
2016-06-13 18:49 ` [Qemu-devel] [Qemu-block] " Markus Armbruster
2016-06-13 19:42 ` Eduardo Habkost
2016-06-14 8:15 ` Markus Armbruster
2016-06-13 19:40 ` Eduardo Habkost
2016-06-10 20:12 ` [Qemu-devel] [RFC v2 3/3] Remove unnecessary variables for function return value Eduardo Habkost
2016-06-10 21:22 ` Eric Blake
2016-06-13 11:29 ` Markus Armbruster
2016-06-13 21:40 ` Eduardo Habkost
2016-06-14 8:13 ` Markus Armbruster
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=575ED8CC.6010601@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=ehabkost@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).