🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27326

Re: [PATCH net-next v2 2/2] cxgb4: use scnprintf() for fw_version

#27326
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 10:04
110 lines
12637 bytes
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
Technical Details
Message-ID: <179646507917.3146.6681406898437849168@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377927-linux-kernel-netdev=dewy.ru
References: <20261204094816.116-2-chenaibing@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377927-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 2/2] cxgb4: use scnprintf() for fw_version
Date: Sat, 05 Dec 2026 10:04:39 +0000
Organization: Usenet Network
Message-ID: <179646507917.3146.6681406898437849168@kernel.org>
References: <20261204094816.116-2-chenaibing@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3003230"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:FlnfTgdL9UTkSih76sEwBXv/36Y= sha256:2H78Mh7v4pR8ml6YWr+zvQcWes2l4jmMvdH4Y8Y/MRM=
	sha1:rl/0B7wVbsDit/er8D2GVlsszIQ= sha256:khgu/9M9N2MpzyY72MI8CbIo6ABwZsTxi4RAp+Si1O8=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 2BBF2117DB2; Sat,  5 Dec 2026 13:05:05 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.541
X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id rryqaevaheJy;
	Sat,  5 Dec 2026 13:05:02 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377927-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id A5331117DDA; Sat,  5 Dec 2026 13:04:53 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id A1F4835041; Sat,  5 Dec 2026 10:04:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796465085;
	b=dGIB83ZHFWfcmMMyEkaymaEP/84OTG6xyfFdhxFUQOS0qiHUDjpsU/4ROPHdPKcI1VkX
	 YO/8RqsFYSuvIuqe+B8T0M4T6hLs6ykH3ymQ7l5CKWXtAaCr+75HdEIu78ycfol3i7pu+
	 XPByK71OGoLlPSlQGb371tcoAYkfwuC+iUJOizw7dBrCJs7FG/r3LVFGT7lIvrhgJil7V
	 20wbhWL4Ym1ATFS25UQ68qHCqUj3ezNOLSoHGVpoAKOvFiW4R2XlX9LRcaw5/PJzhF1ud
	 CBVjC165rrQ2C8GsdKdU4vWOOSm7bwazYuOwLEUl1QHNCzt9MP9f6BkmZRCoWkw4T3g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796465085;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=hYW6jWXKexxQWATAY92JKCIVWH3c5BUigBd2WnFm8EE=;
	b=PChc+ANaVczXO+ntHU8i+T4yp/OmaiVkKrGXF2wVp7Ul7xT5vxoGoXR9Vo01JGLJRHSG
	 DFSYoyWIomUntETotvds2vSVfZr55hg4W342XdWc6+ZGOF7cVsFEylZEroGHg7ea9sErU
	 OVHnfybf76N4YOyAisNyhVlXHpBN2iy710cUP+ZpI9HnfVHELvCb/FX58YZNvUkwrzIkY
	 NbhBCUhrFPYVFGN9OKFkoz7sHVYPGwOF0lAI77AxRLMdVW3q8kb3P6em0g3bgSpOepZhQ
	 jD9FfqerDyMn88OQsYLKphRGo6izno4gHXOz2B4eAFFjhfQxuzRQ9k608RlNsnbl3/g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SROodKoZ;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D0C31606A682;
	Sat,  5 Dec 2026 10:04:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SROodKoZ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796465080;
	b=w6qQVFQiZ8aDqE7wcqunyZwd4S8xXn7u7zDCHCZpQMH0/Puy7/4RBejew6Sfm/+VcY3j
	 Hfe190qppU5gWMywolF43w/tAjcyrm/3CuJp9nAmAZxvreCppWqvkpCNeNbwdid0QeR0x
	 +PUdaXkgM7DhFj61QvEjldZTZLM+tq69d6y2LEGgvB0CW7E+DjSlKb2SwDTZuhOBqxMZB
	 2ZzSYT5wYC2S5xRmkJqIGA/SNH6YYBuapasJIXeS5v4GmgQ5Wlcu7QhKguBHJkq7/K9T5
	 X5KqpdZoVUcIjCswj3QJn0eNyAtkD+VJR2kdIG+YXbhS0ckGd0xcW/lXz/2BNv0lLrg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796465080;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=hYW6jWXKexxQWATAY92JKCIVWH3c5BUigBd2WnFm8EE=;
	b=HI1EdXDhFEt+RblkNEinI7rbQsz7oZNNsEj1l3v9rThCsJY0YdFQ25hbG5cb3/izw+PD
	 nM3kGVDbs5ie9InUxnwwrRneUPkwaevPbRyqGckQFn2amd2gC5HnQZlv601oYU5e8uvbL
	 DE6lGtOYothoma1pYy/XXL7aWHse2ZqjjayhFBLXiyJ/2eg6JfVXTSJL1DUMV6WJsSOq9
	 XHQQLFbKG9v5wnf1nEewgn0QwvIjZw8hHSp5c3FeBsc7AXl1X7SieShsBroL6/CrN24bx
	 vGdLn973zfqNgDpbEwP40AgM+S6riPGU4MIIKnD3kPJ6g/OZkx5gq3Ps9cq1FiAFC/A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SROodKoZ;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id F06A3606A336;
	Sat,  5 Dec 2026 10:04:39 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 911291F00936;
	Sat,  5 Dec 2026 10:04:39 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796465079;
	bh=hYW6jWXKexxQWATAY92JKCIVWH3c5BUigBd2WnFm8EE=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=SROodKoZSK1Fzhh1NgmCZydSV5YRzG5bHf282yE+mBhjhq8SK6yGPz2hN9LlX+WOb
	 VOM80LmEQrHiOhFwRwJ6cG+MZJaI65aezBnoW8ONgN2uJl8eQ+ZJNTuh1PZtT7GT/5
	 wH1R/ksmAAkz16pzbQs+GZimyDTHlSUoMlnsJqQH6uQDDsodlxMbLmw9xmKnb01/Su
	 MnJVHuFbqitl/EndvjaWu0aWNZu5DKuZubnbL1VQ8fRfVFS72PG6OcaMcfBZ+n3t0w
	 D8RjElJGzcyDq9mo1U6cMi8hOCSRErq3BIZrTP5fI+8ST5XOs4mic/IiUNs2+SMWAY
	 Spm1lfF7AVQjQ==
X-Cc: willemdebruijn.kernel@gmail.com, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org, kuba@kernel.org
X-In-Reply-To: <20261204094816.116-2-chenaibing@cmss.chinamobile.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list