mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qianfeng Rong <rongqianfeng@vivo.com>
To: Lizhi Hou <lizhi.hou@amd.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: Thu, 28 Aug 2025 10:16:17 +0800	[thread overview]
Message-ID: <b7438e06-b747-4afd-8581-fba671a35a4e@vivo.com> (raw)
In-Reply-To: <6222cb69-fbb5-07b8-043c-cf0c25c9f3f0@amd.com>


在 2025/8/28 1:18, Lizhi Hou 写道:
>
> 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.


Thank you for letting me know about this. I will submit the v2 version.

Best regards,
Qianfeng

>
> Lizhi
>
>>
>> Best regards,
>> Qianfeng
>>

      reply	other threads:[~2025-08-28  2:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-26  7:29 Qianfeng Rong
2025-08-26 16:31 ` Lizhi Hou
2025-08-27  2:15   ` Qianfeng Rong
2025-08-27 17:18     ` Lizhi Hou
2025-08-28  2:16       ` Qianfeng Rong [this message]

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=b7438e06-b747-4afd-8581-fba671a35a4e@vivo.com \
    --to=rongqianfeng@vivo.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhi.hou@amd.com \
    --cc=min.ma@amd.com \
    --cc=ogabbay@kernel.org \
    /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

all inboxes | Powered by JetHome®