On 8/26/25 19:15, Qianfeng Rong wrote:

在 2025/8/27 0:31, Lizhi Hou 写道:

On 8/26/25 00:29, Qianfeng Rong wrote:
Change the 'ret' variable from u32 to int to store -EINVAL, reducing
potential risks such as incorrect results when comparing 'ret' with
error codes.

Sounds this fixes code issue. Could you add "Fixes" tag?



The 'ret' variable stores negative error codes directly.  Storing
error codes in u32 (an unsigned type) causes no runtime issues but is
stylistically inconsistent and very ugly.

Logical errors with 'ret' only occur when it is compared against negative
error codes. For example:

u32 ret = -EINVAL; // ret becomes an extremely large unsigned integer

if (ret == -EINVAL) // This condition will never be true

This patch reduces the likelihood of such issues occurring. Since it does
not fix an existing bug, I believe there is no need to add a Fixes tag.

I agree with the change.

u32 ret = -EINVAL may lead to a gcc warning if -Wsign-conversion is enabled. That is why I suggested Fixes tag.

Lizhi


Best regards,
Qianfeng

Reply via email to