]> www.infradead.org Git - users/hch/misc.git/commitdiff
eth: bnxt: fix string truncation warning in FW version
authorJakub Kicinski <kuba@kernel.org>
Fri, 17 Jan 2025 18:37:26 +0000 (10:37 -0800)
committerJakub Kicinski <kuba@kernel.org>
Sun, 19 Jan 2025 01:32:45 +0000 (17:32 -0800)
W=1 builds with gcc 14.2.1 report:

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c:4193:32: error: ā€˜%s’ directive output may be truncated writing up to 31 bytes into a region of size 27 [-Werror=format-truncation=]
 4193 |                          "/pkg %s", buf);

It's upset that we let buf be full length but then we use 5
characters for "/pkg ".

The builds is also clear with clang version 19.1.5 now.

Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20250117183726.1481524-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

index 540c140d52dcfed42508693e1340e98ec2d9dc68..65a20931c579643fc052d2107a1d651b8512d448 100644 (file)
@@ -4184,7 +4184,7 @@ err:
 static void bnxt_get_pkgver(struct net_device *dev)
 {
        struct bnxt *bp = netdev_priv(dev);
-       char buf[FW_VER_STR_LEN];
+       char buf[FW_VER_STR_LEN - 5];
        int len;
 
        if (!bnxt_get_pkginfo(dev, buf, sizeof(buf))) {