From: netdev-bot+sashiko@kernel.org
To: chenaibing@cmss.chinamobile.com
Cc: willemdebruijn.kernel@gmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, kuba@kernel.org
Subject: Re: [PATCH net-next v2 2/2] cxgb4: use scnprintf() for fw_version
Date: Sat, 05 Dec 2026 10:04:39 +0000 [thread overview]
Message-ID: <179646507917.3146.6681406898437849168@kernel.org> (raw)
In-Reply-To: <20261204094816.116-2-chenaibing@cmss.chinamobile.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2 (1)
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The patch leaves the same construct unfixed in the sibling
cxgb4vf driver.
- [Low] The commit message misdescribes what the change does.
- [Low] The continuation lines of the call are left inconsistently
aligned.
Pre-existing issues:
- [Low] This problem wasn't introduced by this patch, but get_drvinfo()
in drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c can still format…
--
cxgb4: use scnprintf() for fw_version
This commit changes get_drvinfo() in cxgb4 to format info->fw_version with
scnprintf() instead of snprintf(). The goal is to silence a
-Wformat-truncation error that the kernel test robot reported for W=1
builds with CONFIG_WERROR.
Link: https://lore.kernel.org/oe-kbuild-all/202604141419.a4vuNBN7-lkp@intel.com/
> Use scnprintf(), which returns the number of bytes written, so the string
> is bounded by the field and the intent is visible at the call site.
[Severity: Low]
Is this description accurate? snprintf() already limited the string to
size - 1 bytes plus a NUL. scnprintf() writes exactly the same bytes and
differs only in its return value, which get_drvinfo() discards.
The warning seems to go away only because GCC's format-truncation analysis
covers the snprintf()/vsnprintf() built-ins. scnprintf() is a plain kernel
function declared with __printf(3, 4) in include/linux/sprintf.h, so GCC
doesn't check it.
The diagnostic was a true positive, since 35 characters can exceed the 31
usable bytes. Could the changelog say that the warning is being
suppressed, and that the ", TP ..." suffix can still be truncated?
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
> index c72c0bcd45c80..7c88bc8102d7d 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
> @@ -205,8 +205,8 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
> info->regdump_len = get_regs_len(dev);
>
> if (adapter->params.fw_vers)
> - snprintf(info->fw_version, sizeof(info->fw_version),
> - "%u.%u.%u.%u, TP %u.%u.%u.%u",
> + scnprintf(info->fw_version, sizeof(info->fw_version),
> + "%u.%u.%u.%u, TP %u.%u.%u.%u",
[Severity: Medium]
Does the same build failure still happen in the sibling cxgb4vf driver?
cxgb4vf_get_drvinfo() in drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
still has the same construct:
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
"%u.%u.%u.%u, TP %u.%u.%u.%u",
FW_HDR_FW_VER_MAJOR_G(adapter->params.dev.fwrev),
FW_HDR_FW_VER_MINOR_G(adapter->params.dev.fwrev),
FW_HDR_FW_VER_MICRO_G(adapter->params.dev.fwrev),
...
It uses the same FW_HDR_FW_VER_*_G() accessors from cxgb4/t4fw_api.h,
whose masks are all 0xff. It also writes into the same 32-byte fw_version
field, so GCC should compute the same 35-character worst case.
scripts/Makefile.warn adds -Wno-format-truncation only outside of W=1. A
W=1 build with CONFIG_WERROR (or W=e) and CONFIG_CHELSIO_T4VF enabled, such
as allmodconfig, would therefore still fail.
The commit message describes this build failure as resolved. Should
cxgb4vf be handled in the same patch?
[Severity: Low]
This isn't a bug introduced by this patch, but get_drvinfo() can still
format more characters than info->fw_version can hold. The field is
ETHTOOL_FWVERS_LEN (32) bytes. With eight 0xff-masked fields, the worst
case is 24 digits + 6 dots + ", TP " = 35 characters.
In that case, the TP revision reported by ethtool -i is silently cut, for
example "200.100.200.100, TP 200.100.20". The switch to scnprintf() doesn't
change where the truncation happens. It only removes the warning that
pointed to it.
> FW_HDR_FW_VER_MAJOR_G(adapter->params.fw_vers),
> FW_HDR_FW_VER_MINOR_G(adapter->params.fw_vers),
> FW_HDR_FW_VER_MICRO_G(adapter->params.fw_vers),
[Severity: Low]
This isn't a bug, but only the format string line was re-indented to
match the new scnprintf( parenthesis. The eight FW_HDR_FW_VER_*_G()
argument lines keep the old alignment that matched snprintf(, so one call
now has mixed continuation indentation. Could these lines be re-aligned
too?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204094816.116-1-chenaibing%40cmss.chinamobile.com
next prev parent reply other threads:[~2026-12-05 10:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 9:48 [PATCH net-next v2 1/2] cxgb4: size the MSI-X interrupt name buffer Aibing Chen
2026-12-04 9:48 ` [PATCH net-next v2 2/2] cxgb4: use scnprintf() for fw_version Aibing Chen
2026-12-05 10:04 ` netdev-bot+sashiko [this message]
2026-12-05 10:04 ` [PATCH net-next v2 1/2] cxgb4: size the MSI-X interrupt name buffer netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179646507917.3146.6681406898437849168@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=chenaibing@cmss.chinamobile.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox