qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qom: abort on error in property setter if calle


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH] qom: abort on error in property setter if caller passed errp == NULL
Date: Thu, 28 Nov 2013 16:03:29 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Paolo Bonzini <address@hidden> writes:

> Il 28/11/2013 14:23, Igor Mammedov ha scritto:
>> > object_property_set(Foo, bar, "baz", &abort_on_err);
>> 
>> that is just another way to put burden on caller, instead of doing it
>> in one place.
>
> It's also much more self-documenting.
>
> The problem is that there is one very good case where you want the
> silent-don't-care behavior: when you don't care about the exact error,
> and you can figure out whether there was an error from the returned
> value of the function.  This doesn't apply to object_property_set of
> course, but it is the reason why NULL Error* has silent-don't-care behavior.
>
> Now, let's look at the alternatives:
>
> * keep silent don't care
>   + consistent
>   + predictable
>   - not always handy
>
> * only modify object_property_set
>   + mostly does the right thing
>   - inconsistent with other Error* functions
>   - inconsistent with _nofail functions
>
> * Peter's alternative
>   + self-documenting
>   + consistent
>   + predictable
>
> * make Error* mandatory for all void functions
>   + consistent
>   + almost predictable (because in C you can ignore return values)
>   - not necessarily does the right thing (e.g. cleanup functions)
>   - requires manual effort to abide to the policy
>
> I vote for Peter's proposal, or for adding object_property_set_nofail.
> No particular preference.
>
> Another variant: modify object_property_set to add a g_warning.  I think
> it's fine.  It reduces the inconsistency, and still simplifies debugging.

I like Peter's proposal, provided we use it to get rid of the _nofail
pattern.

Second preference is adding another _nofail wrapper.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]