[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH v2 2/3] error: Remove unnecessary l
Re: [Qemu-block] [Qemu-devel] [PATCH v2 2/3] error: Remove unnecessary local_err variables
Mon, 13 Jun 2016 10:01:16 -0600
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
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);
>> error_setg(errp, ...);
>> The latter aborts when @errp already contains an error, the former does
> 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
Description: OpenPGP digital signature
[Qemu-block] [RFC v2 3/3] Remove unnecessary variables for function return value, Eduardo Habkost, 2016/06/10
[Qemu-block] [PATCH v2 1/3] error: Remove NULL checks on error_propagate() calls, Eduardo Habkost, 2016/06/10