diff mbox series

amd-xgbe: remove h from printk format specifier

Message ID 20201223194345.125205-1-trix@redhat.com (mailing list archive)
State Deferred
Delegated to: Netdev Maintainers
Headers show
Series amd-xgbe: remove h from printk format specifier | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Tom Rix Dec. 23, 2020, 7:43 p.m. UTC
From: Tom Rix <trix@redhat.com>

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

Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Joe Perches Dec. 23, 2020, 8:14 p.m. UTC | #1
On Wed, 2020-12-23 at 11:43 -0800, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
> 
> 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",

> 
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>  drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 6 +++---
>  1 file 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 61f39a0e04f9..3c18f26bf2a5 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
> @@ -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;
>  		}
Tom Rix Dec. 23, 2020, 8:33 p.m. UTC | #2
On 12/23/20 12:14 PM, Joe Perches wrote:
> On Wed, 2020-12-23 at 11:43 -0800, trix@redhat.com wrote:
>> From: Tom Rix <trix@redhat.com>
>>
>> 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.

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

> $ 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",
>
>> Signed-off-by: Tom Rix <trix@redhat.com>
>> ---
>>  drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 6 +++---
>>  1 file 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 61f39a0e04f9..3c18f26bf2a5 100644
>> --- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
>> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
>> @@ -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;
>>  		}
>
Joe Perches Dec. 23, 2020, 8:53 p.m. UTC | #3
On Wed, 2020-12-23 at 12:33 -0800, Tom Rix wrote:
> On 12/23/20 12:14 PM, Joe Perches wrote:
> > On Wed, 2020-12-23 at 11:43 -0800, trix@redhat.com wrote:
> > > From: Tom Rix <trix@redhat.com>
> > > 
> > > 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.
> 
> 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/
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
index 895d35639129..dcd2a181d43a 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
@@ -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);
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
index d5fd49dd25f3..ff0cd94bb91a 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
@@ -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",
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 2709a2db5657..0ae16bc87833 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -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));
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
index 61f39a0e04f9..3c18f26bf2a5 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
@@ -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",
diff mbox series

Patch

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
index 61f39a0e04f9..3c18f26bf2a5 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
@@ -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;
 		}