dri-devel.lists.freedesktop.org archive mirror
 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: Wed, 27 Aug 2025 10:15:03 +0800	[thread overview]
Message-ID: <eaefefb6-7ced-4c47-8bff-bae83f143b72@vivo.com> (raw)
In-Reply-To: <51440ea7-bbea-c890-057e-109685a72cb3@amd.com>


在 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.

Best regards,
Qianfeng


  reply	other threads:[~2025-08-27  2:15 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 [this message]
2025-08-27 17:18     ` Lizhi Hou
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=eaefefb6-7ced-4c47-8bff-bae83f143b72@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;
as well as URLs for NNTP newsgroup(s).