diff mbox series

net: txgbe: clean up PBA string

Message ID 20231016094831.139939-1-jiawenwu@trustnetic.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: txgbe: clean up PBA string | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1360 this patch: 1360
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1385 this patch: 1385
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1385 this patch: 1385
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jiawen Wu Oct. 16, 2023, 9:48 a.m. UTC
Replace deprecated strncpy with strscpy, and add the missing PBA prints.

This issue is reported by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/netdev/002101d9ffdd$9ea59f90$dbf0deb0$@trustnetic.com/T/#t

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/ethernet/wangxun/txgbe/txgbe_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andrew Lunn Oct. 16, 2023, 7:19 p.m. UTC | #1
On Mon, Oct 16, 2023 at 05:48:31PM +0800, Jiawen Wu wrote:
> Replace deprecated strncpy with strscpy, and add the missing PBA prints.
> 
> This issue is reported by: Justin Stitt <justinstitt@google.com>
> Link: https://lore.kernel.org/netdev/002101d9ffdd$9ea59f90$dbf0deb0$@trustnetic.com/T/#t
> 
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> ---
>  drivers/net/ethernet/wangxun/txgbe/txgbe_main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
> index 394f699c51da..123e3ca78ef0 100644
> --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
> +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
> @@ -741,8 +741,9 @@ static int txgbe_probe(struct pci_dev *pdev,
>  	/* First try to read PBA as a string */
>  	err = txgbe_read_pba_string(wx, part_str, TXGBE_PBANUM_LENGTH);
>  	if (err)
> -		strncpy(part_str, "Unknown", TXGBE_PBANUM_LENGTH);
> +		strscpy(part_str, "Unknown", sizeof(part_str));
>  
> +	netif_info(wx, probe, netdev, "PBA No: %s\n", part_str);
>  	netif_info(wx, probe, netdev, "%pM\n", netdev->dev_addr);

In general, we try not to spam the kernel log, especially not for the
good case. You can get the MAC address with ip link show. How
important is the part? Can you get the same information from lspci?
Or maybe you could append it to the driver name in wx_get_drvinfo()?

	Andrew
Jiawen Wu Oct. 17, 2023, 6:55 a.m. UTC | #2
On Tuesday, October 17, 2023 3:19 AM, Andrew Lunn wrote:
> On Mon, Oct 16, 2023 at 05:48:31PM +0800, Jiawen Wu wrote:
> > Replace deprecated strncpy with strscpy, and add the missing PBA prints.
> >
> > This issue is reported by: Justin Stitt <justinstitt@google.com>
> > Link: https://lore.kernel.org/netdev/002101d9ffdd$9ea59f90$dbf0deb0$@trustnetic.com/T/#t
> >
> > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> > ---
> >  drivers/net/ethernet/wangxun/txgbe/txgbe_main.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
> > index 394f699c51da..123e3ca78ef0 100644
> > --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
> > +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
> > @@ -741,8 +741,9 @@ static int txgbe_probe(struct pci_dev *pdev,
> >  	/* First try to read PBA as a string */
> >  	err = txgbe_read_pba_string(wx, part_str, TXGBE_PBANUM_LENGTH);
> >  	if (err)
> > -		strncpy(part_str, "Unknown", TXGBE_PBANUM_LENGTH);
> > +		strscpy(part_str, "Unknown", sizeof(part_str));
> >
> > +	netif_info(wx, probe, netdev, "PBA No: %s\n", part_str);
> >  	netif_info(wx, probe, netdev, "%pM\n", netdev->dev_addr);
> 
> In general, we try not to spam the kernel log, especially not for the
> good case. You can get the MAC address with ip link show. How
> important is the part? Can you get the same information from lspci?
> Or maybe you could append it to the driver name in wx_get_drvinfo()?

PBA info can be read from lspci, also the log for MAC address can be removed.
I'll submit a patch to clean them up in txgbe/ngbe.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
index 394f699c51da..123e3ca78ef0 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
@@ -741,8 +741,9 @@  static int txgbe_probe(struct pci_dev *pdev,
 	/* First try to read PBA as a string */
 	err = txgbe_read_pba_string(wx, part_str, TXGBE_PBANUM_LENGTH);
 	if (err)
-		strncpy(part_str, "Unknown", TXGBE_PBANUM_LENGTH);
+		strscpy(part_str, "Unknown", sizeof(part_str));
 
+	netif_info(wx, probe, netdev, "PBA No: %s\n", part_str);
 	netif_info(wx, probe, netdev, "%pM\n", netdev->dev_addr);
 
 	return 0;