[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] Error propagation in generated visitors and command mar
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] Error propagation in generated visitors and command marshallers |
Date: |
Wed, 09 Apr 2014 10:34:24 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
On 04/09/2014 09:48 AM, Markus Armbruster wrote:
> I stumbled over this while trying to purge error_is_set() from the code.
>
> But: is it a good idea to have both patterns in the code? Should we
> perhaps use the common pattern for visiting, too? Like this:
>
> visit_type_str(v, &foo, "foo", &err);
> if (err) {
> goto out;
> }
> visit_type_str(v, &bar, "bar", &err);
> if (err) {
> goto out;
> }
>
> Then we can assume *errp is clear on function entry, like this:
>
> void visit_type_str(Visitor *v, char **obj, const char *name, Error
> **errp)
> {
> v->type_str(v, obj, name, errp);
> }
>
> Should execute roughly the same number of conditional branches.
>
> Tedious repetition of "if (err) goto out" in the caller, but that's what
> we do elsewhere, and unlike elsewhere, these one's are generated.
>
> Opinions?
Putting the tedium into the generated code is WHY we have generated
code; so that the rest of the code that is hand-written can be concise.
I like this latter idea of letting the visitors assume that errp is
clean on entry with the caller responsible for checking err after each step.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature