netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] amd-xgbe: Use int type to store negative error codes
@ 2025-08-26 14:21 Qianfeng Rong
  2025-08-27 22:20 ` Jacob Keller
  2025-08-28  1:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Qianfeng Rong @ 2025-08-26 14:21 UTC (permalink / raw)
  To: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Qianfeng Rong

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.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.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;
 
 	if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
 	    rxfh->hfunc != ETH_RSS_HASH_TOP) {
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-i2c.c b/drivers/net/ethernet/amd/xgbe/xgbe-i2c.c
index d40011e8ddf2..65eb7b577b65 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-i2c.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-i2c.c
@@ -70,7 +70,7 @@ static int xgbe_i2c_set_enable(struct xgbe_prv_data *pdata, bool enable)
 
 static int xgbe_i2c_disable(struct xgbe_prv_data *pdata)
 {
-	unsigned int ret;
+	int ret;
 
 	ret = xgbe_i2c_set_enable(pdata, false);
 	if (ret) {
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
index 23c39e92e783..a56efc1bee33 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
@@ -2902,7 +2902,7 @@ static void xgbe_phy_sfp_setup(struct xgbe_prv_data *pdata)
 static int xgbe_phy_int_mdio_reset(struct xgbe_prv_data *pdata)
 {
 	struct xgbe_phy_data *phy_data = pdata->phy_data;
-	unsigned int ret;
+	int ret;
 
 	ret = pdata->hw_if.set_gpio(pdata, phy_data->mdio_reset_gpio);
 	if (ret)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] amd-xgbe: Use int type to store negative error codes
  2025-08-26 14:21 [PATCH] amd-xgbe: Use int type to store negative error codes Qianfeng Rong
@ 2025-08-27 22:20 ` Jacob Keller
  2025-08-28  1:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jacob Keller @ 2025-08-27 22:20 UTC (permalink / raw)
  To: Qianfeng Rong, Shyam Sundar S K, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1767 bytes --]



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@vivo.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@intel.com>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] amd-xgbe: Use int type to store negative error codes
  2025-08-26 14:21 [PATCH] amd-xgbe: Use int type to store negative error codes Qianfeng Rong
  2025-08-27 22:20 ` Jacob Keller
@ 2025-08-28  1:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-28  1:10 UTC (permalink / raw)
  To: Qianfeng Rong
  Cc: Shyam-sundar.S-k, andrew+netdev, davem, edumazet, kuba, pabeni,
	netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 26 Aug 2025 22:21:59 +0800 you 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.
> 
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> 
> [...]

Here is the summary with links:
  - amd-xgbe: Use int type to store negative error codes
    https://git.kernel.org/netdev/net-next/c/a6bac1822931

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-28  1:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-26 14:21 [PATCH] amd-xgbe: Use int type to store negative error codes Qianfeng Rong
2025-08-27 22:20 ` Jacob Keller
2025-08-28  1:10 ` patchwork-bot+netdevbpf

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