qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v17 09/16] util/log: Add Error argument to qemu_str_to_log_ma


From: Richard Henderson
Subject: Re: [PATCH v17 09/16] util/log: Add Error argument to qemu_str_to_log_mask
Date: Sun, 15 Oct 2023 11:55:59 -0700
User-agent: Mozilla Thunderbird

On 10/10/23 05:55, Markus Armbruster wrote:
Richard Henderson <richard.henderson@linaro.org> writes:

Do not rely on return value of 0 to indicate error,
pass along an Error pointer to be set.

Not wrong, but goes against error.h's recommendation

  * - Whenever practical, also return a value that indicates success /
  *   failure.  This can make the error checking more concise, and can
  *   avoid useless error object creation and destruction.  Note that
  *   we still have many functions returning void.  We recommend
  *   • bool-valued functions return true on success / false on failure,
  *   • pointer-valued functions return non-null / null pointer, and
  *   • integer-valued functions return non-negative / negative.

...
Returning -1 here would stick to error.h's recommendation.

The problem had been that 0 would become a valid result in the next patch.
But using -1 would work, particularly with bit 31 of the log mask as yet unused.


r~




reply via email to

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