Skip to contentSkip to conversation

amd-xgbe: remove h from printk format specifier

PATCH In review [email protected] 2 participants 4 messages Dec 23, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amd-xgbe: remove h from printk format specifier

From: Tom Rix <[email protected]>

This change fixes the checkpatch warning described in this commit
commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")

Standard integer promotion is already done and %hx and %hhx is useless so do not encourage the use of %hh[xudi] or %h[xudi].

---
 drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +3 -3
index 61f39a0e04f9..3c18f26bf2a5 100644
@@ -339,14 +339,14 @@ static int xgbe_set_link_ksettings(struct net_device *netdev,
 	speed = cmd->base.speed;
 
 	if (cmd->base.phy_address != pdata->phy.address) {
-		netdev_err(netdev, "invalid phy address %hhu\n",
+		netdev_err(netdev, "invalid phy address %u\n",
 			   cmd->base.phy_address);
 		return -EINVAL;
 	}
 
 	if ((cmd->base.autoneg != AUTONEG_ENABLE) &&
 	    (cmd->base.autoneg != AUTONEG_DISABLE)) {
-		netdev_err(netdev, "unsupported autoneg %hhu\n",
+		netdev_err(netdev, "unsupported autoneg %u\n",
 			   cmd->base.autoneg);
 		return -EINVAL;
 	}
@@ -358,7 +358,7 @@ static int xgbe_set_link_ksettings(struct net_device *netdev,
 		}
 
 		if (cmd->base.duplex != DUPLEX_FULL) {
-			netdev_err(netdev, "unsupported duplex %hhu\n",
+			netdev_err(netdev, "unsupported duplex %u\n",
 				   cmd->base.duplex);
 			return -EINVAL;
 		}
Signature · 1 line
2.27.0
#1 lore raw
Quoted 7 lines · On Wed, 2020-12-23 at 11:43 -0800, [email protected] wrote:

From: Tom Rix <[email protected]>

This change fixes the checkpatch warning described in this commit
commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")

Standard integer promotion is already done and %hx and %hhx is useless so do not encourage the use of %hh[xudi] or %h[xudi].

Why only xgbe-ethtool?

Perhaps your script only converts direct uses of functions marked with __printf and not any uses of the same functions via macros.

$ git grep -P '%[\w\d\.]*h\w' drivers/net/ethernet/amd/xgbe/
drivers/net/ethernet/amd/xgbe/xgbe-dcb.c:                         "TC%u: tx_bw=%hhu, rx_bw=%hhu, tsa=%hhu\n", i,
drivers/net/ethernet/amd/xgbe/xgbe-dcb.c:               netif_dbg(pdata, drv, netdev, "PRIO%u: TC=%hhu\n", i,
drivers/net/ethernet/amd/xgbe/xgbe-dcb.c:                                 "unsupported TSA algorithm (%hhu)\n",
drivers/net/ethernet/amd/xgbe/xgbe-dcb.c:                 "cap=%hhu, en=%#hhx, mbc=%hhu, delay=%hhu\n",
drivers/net/ethernet/amd/xgbe/xgbe-dev.c:       netif_dbg(pdata, drv, pdata->netdev, "VXLAN tunnel id set to %hx\n",
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c:           netdev_err(netdev, "invalid phy address %hhu\n",
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c:           netdev_err(netdev, "unsupported autoneg %hhu\n",
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c:                   netdev_err(netdev, "unsupported duplex %hhu\n",
Quoted 39 lines

---
 drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 6 +++---

 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +0 -0
index 61f39a0e04f9..3c18f26bf2a5 100644
@@ -339,14 +339,14 @@ static int xgbe_set_link_ksettings(struct net_device *netdev,
  	speed = cmd->base.speed;

  if (cmd->base.phy_address != pdata->phy.address) {

drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +1 -1
-		netdev_err(netdev, "invalid phy address %hhu\n",
+		netdev_err(netdev, "invalid phy address %u\n",

  cmd->base.phy_address); return -EINVAL;
  }

  if ((cmd->base.autoneg != AUTONEG_ENABLE) && (cmd->base.autoneg != AUTONEG_DISABLE)) {

drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +1 -1
-		netdev_err(netdev, "unsupported autoneg %hhu\n",
+		netdev_err(netdev, "unsupported autoneg %u\n",

  cmd->base.autoneg);
  return -EINVAL;
  }

drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +0 -0
@@ -358,7 +358,7 @@ static int xgbe_set_link_ksettings(struct net_device *netdev,
  		}

  if (cmd->base.duplex != DUPLEX_FULL) {

drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +1 -1
-			netdev_err(netdev, "unsupported duplex %hhu\n",
+			netdev_err(netdev, "unsupported duplex %u\n",

  cmd->base.duplex); return -EINVAL;
  }

author
#2 lore raw
Quoted 6 lines · Joe Perches
Quoted 5 lines · On Wed, 2020-12-23 at 11:43 -0800, [email protected] wrote:

From: Tom Rix <[email protected]>

This change fixes the checkpatch warning described in this commit
commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")

Quoted 7 lines
Quoted 2 lines

Standard integer promotion is already done and %hx and %hhx is useless so do not encourage the use of %hh[xudi] or %h[xudi].

Why only xgbe-ethtool?

Perhaps your script only converts direct uses of functions marked with __printf and not any uses of the same functions via macros.

The fixer may have issues.

A works as designed by not desired is it only fixes what it compiles and if a

macro is #if-def away then it will not do the fix.  This is troublesome for the

the *_debug() routines.  So I am rejecting files with partial fixes.

It is also likely I missed adding __printf attributes.

There will be enough changes for this pass through to count as my feat of strength for today.

Tom

Quoted 49 lines
$ git grep -P '%[\w\d\.]*h\w' drivers/net/ethernet/amd/xgbe/
drivers/net/ethernet/amd/xgbe/xgbe-dcb.c:                         "TC%u: tx_bw=%hhu, rx_bw=%hhu, tsa=%hhu\n", i,
drivers/net/ethernet/amd/xgbe/xgbe-dcb.c:               netif_dbg(pdata, drv, netdev, "PRIO%u: TC=%hhu\n", i,
drivers/net/ethernet/amd/xgbe/xgbe-dcb.c:                                 "unsupported TSA algorithm (%hhu)\n",
drivers/net/ethernet/amd/xgbe/xgbe-dcb.c:                 "cap=%hhu, en=%#hhx, mbc=%hhu, delay=%hhu\n",
drivers/net/ethernet/amd/xgbe/xgbe-dev.c:       netif_dbg(pdata, drv, pdata->netdev, "VXLAN tunnel id set to %hx\n",
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c:           netdev_err(netdev, "invalid phy address %hhu\n",
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c:           netdev_err(netdev, "unsupported autoneg %hhu\n",
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c:                   netdev_err(netdev, "unsupported duplex %hhu\n",
Quoted 38 lines

---
 drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 6 +++---

 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +0 -0
index 61f39a0e04f9..3c18f26bf2a5 100644
@@ -339,14 +339,14 @@ static int xgbe_set_link_ksettings(struct net_device *netdev,
  	speed = cmd->base.speed;

  if (cmd->base.phy_address != pdata->phy.address) {

drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +1 -1
-		netdev_err(netdev, "invalid phy address %hhu\n",
+		netdev_err(netdev, "invalid phy address %u\n",

  cmd->base.phy_address); return -EINVAL;
  }

  if ((cmd->base.autoneg != AUTONEG_ENABLE) && (cmd->base.autoneg != AUTONEG_DISABLE)) {

drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +1 -1
-		netdev_err(netdev, "unsupported autoneg %hhu\n",
+		netdev_err(netdev, "unsupported autoneg %u\n",

  cmd->base.autoneg);
  return -EINVAL;
  }

drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +0 -0
@@ -358,7 +358,7 @@ static int xgbe_set_link_ksettings(struct net_device *netdev,
  		}

  if (cmd->base.duplex != DUPLEX_FULL) {

drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +1 -1
-			netdev_err(netdev, "unsupported duplex %hhu\n",
+			netdev_err(netdev, "unsupported duplex %u\n",

  cmd->base.duplex); return -EINVAL;
  }

#3 lore raw
Quoted 9 lines · Tom Rix
Quoted 8 lines · Joe Perches
Quoted 7 lines · On Wed, 2020-12-23 at 11:43 -0800, [email protected] wrote:

From: Tom Rix <[email protected]>

This change fixes the checkpatch warning described in this commit
commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")

Standard integer promotion is already done and %hx and %hhx is useless so do not encourage the use of %hh[xudi] or %h[xudi].

Quoted 7 lines
Quoted 5 lines

Why only xgbe-ethtool?

Perhaps your script only converts direct uses of functions marked with __printf and not any uses of the same functions via macros.

The fixer may have issues.

Perhaps until the fixer is fixed, it'd be more
complete coverage to use checkpatch like:

$ git ls-files <path> | \
  xargs ./scripts/checkpatch.pl -f --fix-inplace --types=unnecessary_modifier

e.g.:

$ git ls-files drivers/net/ethernet/amd/xgbe | \
  xargs ./scripts/checkpatch.pl -f --fix-inplace --types=unnecessary_modifier
$ git diff -U0 drivers/net/ethernet/amd/xgbe/
drivers/net/ethernet/amd/xgbe/xgbe-dcb.c +4 -4
index 895d35639129..dcd2a181d43a 100644
@@ -155 +155 @@ static int xgbe_dcb_ieee_setets(struct net_device *netdev,
-                         "TC%u: tx_bw=%hhu, rx_bw=%hhu, tsa=%hhu\n", i,
+                         "TC%u: tx_bw=%u, rx_bw=%u, tsa=%u\n", i,
@@ -158 +158 @@ static int xgbe_dcb_ieee_setets(struct net_device *netdev,
-               netif_dbg(pdata, drv, netdev, "PRIO%u: TC=%hhu\n", i,
+               netif_dbg(pdata, drv, netdev, "PRIO%u: TC=%u\n", i,
@@ -233 +233 @@ static int xgbe_dcb_ieee_setpfc(struct net_device *netdev,
-                 "cap=%hhu, en=%#hhx, mbc=%hhu, delay=%hhu\n",
+                 "cap=%u, en=%#x, mbc=%u, delay=%u\n",
@@ -267 +267 @@ static u8 xgbe_dcb_setdcbx(struct net_device *netdev, u8 dcbx)
-       netif_dbg(pdata, drv, netdev, "DCBX=%#hhx\n", dcbx);
+       netif_dbg(pdata, drv, netdev, "DCBX=%#x\n", dcbx);
drivers/net/ethernet/amd/xgbe/xgbe-dev.c +1 -1
index d5fd49dd25f3..ff0cd94bb91a 100644
@@ -488 +488 @@ static void xgbe_set_vxlan_id(struct xgbe_prv_data *pdata)
-       netif_dbg(pdata, drv, pdata->netdev, "VXLAN tunnel id set to %hx\n",
+       netif_dbg(pdata, drv, pdata->netdev, "VXLAN tunnel id set to %x\n",
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +1 -1
index 2709a2db5657..0ae16bc87833 100644
@@ -2781 +2781 @@ void xgbe_print_pkt(struct net_device *netdev, struct sk_buff *skb, bool tx_rx)
-       netdev_dbg(netdev, "Protocol: %#06hx\n", ntohs(eth->h_proto));
+       netdev_dbg(netdev, "Protocol: %#06x\n", ntohs(eth->h_proto));
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +3 -3
index 61f39a0e04f9..3c18f26bf2a5 100644
@@ -342 +342 @@ static int xgbe_set_link_ksettings(struct net_device *netdev,
-               netdev_err(netdev, "invalid phy address %hhu\n",
+               netdev_err(netdev, "invalid phy address %u\n",
@@ -349 +349 @@ static int xgbe_set_link_ksettings(struct net_device *netdev,
-               netdev_err(netdev, "unsupported autoneg %hhu\n",
+               netdev_err(netdev, "unsupported autoneg %u\n",
@@ -361 +361 @@ static int xgbe_set_link_ksettings(struct net_device *netdev,
-                       netdev_err(netdev, "unsupported duplex %hhu\n",
+                       netdev_err(netdev, "unsupported duplex %u\n",