Philippe Mathieu-Daudé <[email protected]> writes:
> On 9/13/21 3:08 PM, Markus Armbruster wrote:
>> Markus Armbruster <[email protected]> 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.