Re: [PATCH] amd-xgbe: remove h from printk format specifier

From: Tom Rix
Date: Wed Dec 23 2020 - 15:35:46 EST



On 12/23/20 12:14 PM, Joe Perches wrote:
> On Wed, 2020-12-23 at 11:43 -0800, trix@xxxxxxxxxx wrote:
>> From: Tom Rix <trix@xxxxxxxxxx>
>>
>> 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@xxxxxxxxxx>
>> ---
>>  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;
>>   }
>