Re: [PATCH] amd-xgbe: Use int type to store negative error codes
From: Jacob Keller
Date: Wed Aug 27 2025 - 18:23:53 EST
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@xxxxxxxx>
> ---
> 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@xxxxxxxxx>
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature