[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <47ed10fc-4445-44ba-be79-dc90b7e7d0e3@intel.com>
Date: Wed, 27 Aug 2025 15:20:04 -0700
From: Jacob Keller <jacob.e.keller@...el.com>
To: Qianfeng Rong <rongqianfeng@...o.com>, Shyam Sundar S K
<Shyam-sundar.S-k@....com>, Andrew Lunn <andrew+netdev@...n.ch>, "David S.
Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, "Jakub
Kicinski" <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] amd-xgbe: Use int type to store negative error codes
On 8/26/2025 7:21 AM, Qianfeng Rong wrote:
> Use int instead of unsigned int for the 'ret' variable to store return
> values from functions that either return zero on success or negative error
> codes on failure. Storing negative error codes in an unsigned int causes
> no runtime issues, but it's ugly as pants, Change 'ret' from unsigned int
> to int type - this change has no runtime impact.
>
Right, unless you have some sort of signed/unsigned comparison of the
value where you check for ret < 0 for example. Since you just assign to
the local unsigned ret, then return the value as a signed int, this
indeed has no functional change.
> Signed-off-by: Qianfeng Rong <rongqianfeng@...o.com>
> ---
> drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 2 +-
> drivers/net/ethernet/amd/xgbe/xgbe-i2c.c | 2 +-
> drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
> index 35d73306a2d6..b6e1b67a2d0e 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
> @@ -464,7 +464,7 @@ static int xgbe_set_rxfh(struct net_device *netdev,
> {
> struct xgbe_prv_data *pdata = netdev_priv(netdev);
> struct xgbe_hw_if *hw_if = &pdata->hw_if;
> - unsigned int ret;
> + int ret;
>
Looks like this was there from when this was first introduced.
Interestingly, that very same commit f6ac862845bb ("amd-xgbe: Add
receive side scaling ethtool support") used signed integers for the
called functions that assign into ret.
Good to clean this mistake up.
Reviewed-by: Jacob Keller <jacob.e.keller@...el.com>
Download attachment "OpenPGP_signature.asc" of type "application/pgp-signature" (237 bytes)
Powered by blists - more mailing lists