linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lizhi Hou <lizhi.hou@amd.com>
To: Qianfeng Rong <rongqianfeng@vivo.com>, Min Ma <min.ma@amd.com>,
	"Oded Gabbay" <ogabbay@kernel.org>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] accel/amdxdna: Use int instead of u32 to store error codes
Date: Wed, 27 Aug 2025 10:18:12 -0700	[thread overview]
Message-ID: <6222cb69-fbb5-07b8-043c-cf0c25c9f3f0@amd.com> (raw)
In-Reply-To: <eaefefb6-7ced-4c47-8bff-bae83f143b72@vivo.com>


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	other threads:[~2025-08-27 17:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-26  7:29 [PATCH] accel/amdxdna: Use int instead of u32 to store error codes Qianfeng Rong
2025-08-26 16:31 ` Lizhi Hou
2025-08-27  2:15   ` Qianfeng Rong
2025-08-27 17:18     ` Lizhi Hou [this message]
2025-08-28  2:16       ` Qianfeng Rong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6222cb69-fbb5-07b8-043c-cf0c25c9f3f0@amd.com \
    --to=lizhi.hou@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=min.ma@amd.com \
    --cc=ogabbay@kernel.org \
    --cc=rongqianfeng@vivo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).