qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] qapi: define cleanup function for g_autoptr(Error)


From: Markus Armbruster
Subject: Re: [PATCH] qapi: define cleanup function for g_autoptr(Error)
Date: Tue, 14 Sep 2021 06:46:07 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> On 9/13/21 3:08 PM, Markus Armbruster wrote:
>> Markus Armbruster <armbru@redhat.com> writes:

[...]

>> As is, reporting errors doesn't play well with g_autoptr().  Example:
>> 
>>     Error *err = NULL;
>> 
>>     ... code that may set @err ...
>> 
>>     if (error is serious) {
>>         error_report_err(err);
>>     } else {
>>         error_free(err);
>>     }
>
> error_report_err() seems always called within an if()
> statement, so an alternative is to refactor this pattern as:
>
>   void error_report_err_cond(bool condition, Error *err);

It's rarely the only thing done when the condition is true, so it needs
to return it.




reply via email to

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