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
