qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC 00/15] Error API: Flag errors in *errp even if err


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [RFC 00/15] Error API: Flag errors in *errp even if errors are being ignored
Date: Thu, 29 Jun 2017 15:39:58 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0

On 28/06/2017 11:05, Markus Armbruster wrote:
> If foo() additionally returned an indication of success, you could write
> 
>       if (!foo(arg, errp)) {    // assuming foo() returns a bool
>           handle the error...
>       }
> 
> Nicely concise.
> 
> For what it's worth, this is how GLib wants GError to be used.  We
> deviated from it, and it has turned out to be a self-inflicted wound.
> 

I find Eduardo's proposal better.  With GLib's way it's easy to confuse
functions that return 0/-1, 0/-errno, TRUE/FALSE, FALSE/TRUE or
NULL/non-NULL.

Declaring and testing local_err doesn't introduce much boilerplate, it's
propagation to errp that does.  The disadvantage of Eduardo's mechanism
is that it produces slightly worse code, but Error** is rarely used in
hot code.  It could also be improved slightly by changing
ignored_error_unset and ignored_error_set to a 2-element array.

Paolo



reply via email to

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