From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43648242D67;
	Wed, 25 Mar 2026 13:46:04 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201
ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1774446364; cv=none; b=jAelHbtIWSiowmZnyBDuxX7i0tAp811khCr5Mfyq9a2Mq4bbr7PpKXEO6xowVBNfrqAR3tkOzt3m0fWXHaUpJElXSGJtPM4XOWc2+dlqRoo0MCx76btx7B9tjajPdrw5fpLIs4mUCYCMD6EnJ4hEr4122BFIFEeVTZwvybpLatA=
ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1774446364; c=relaxed/simple;
	bh=TSXGQzfP711qrPB0j3RMTHQ/TMRpAy/A6hAklaBDA4k=;
	h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=mx4G4I4CGbhenMlmmyAcSGipU9pa3PoOKnoqtq3amS9hZ0YXw1aU3onzBpaPOZ64mb5tKGlYVh9N58oALncAsKyUKhNyJby0UHGTIhBi4Lrvycpre+DVjo3MzabDVqS+x+j7BfymGeBD1iqiDF3ZSHHfXs1OAPsr3AEb7l6P/ys=
ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J/spztVF; arc=none smtp.client-ip=10.30.226.201
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="J/spztVF"
Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34EB4C4CEF7;
	Wed, 25 Mar 2026 13:46:00 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;
	s=k20201202; t=1774446364;
	bh=TSXGQzfP711qrPB0j3RMTHQ/TMRpAy/A6hAklaBDA4k=;
	h=From:To:Cc:Subject:Date:From;
	b=J/spztVFpXILaV+6ISmNoFIGf1Mui271QWTcRyRoDb3SPrr3NxvDFhuPASQEbQhf8
	 3K4ugQYSfJfFA5Z1JDdkJr05RYbVEcwVqb5JAJY7jRlH5QjoP47pxerzooHtYPyG9r
	 nROPr3OA04hZpxq9YihKZWYR04DshQIa9eBCzPPFObwxQeqyf94IfX/p3TvvXgBTQg
	 Cq6r0O7ufY2SjiUkL32ItHj7p8t02CQABqsFD8uZ20es3Chk61kKFvbSqsLjAJel/V
	 R+C5N+C1OHEInDbsFsjKAwe+pOqGmHnhKQIr9F8tvcM9SSblh85T15PZ8XDDzGm2+b
	 1rhwJWh62NviQ==
From: Arnd Bergmann <arnd@kernel.org>
To: Edward Cree <ecree.xilinx@gmail.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Jeff Garzik <jgarzik@redhat.com>,
	Ben Hutchings <bhutchings@solarflare.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Brett Creeley <brett.creeley@amd.com>,
	Breno Leitao <leitao@debian.org>,
	Kees Cook <kees@kernel.org>,
	netdev@vger.kernel.org,
	linux-net-drivers@amd.com,
	linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev
Subject: [PATCH] [v2] net: sfc: avoid format string warning
Date: Wed, 25 Mar 2026 14:45:44 +0100
Message-Id: <20260325134557.3406655-1-arnd@kernel.org>
X-Mailer: git-send-email 2.39.5
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

From: Arnd Bergmann <arnd@arndb.de>

Three sfc drivers contain the same *_fill_test() function that takes
a format string argument that gets passed down to snprintf(), producing
a warning with clang-22:

drivers/net/ethernet/sfc/falcon/ethtool.c:227:60: error: diagnostic behavior may be improved by adding
      the 'format(printf, 7, 8)' attribute to the declaration of 'ef4_fill_test' [-Werror,-Wmissing-format-attribute]
  210 |                 snprintf(test_str, sizeof(test_str), test_format, test_id);
      |                                                                          ^
drivers/net/ethernet/sfc/falcon/ethtool.c:210:13: note: 'ef4_fill_test' declared here

Rework these to take a varargs based test_format that allows better
type checking and a non-varargs unit name that gets pre-filled by
the caller, so that the compiler can validate all format strings.

Fixes: 3273c2e8c66a ("[netdrvr] sfc: sfc: Add self-test support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: open-code the unit name format as well
    reformat the function prototype
---
 drivers/net/ethernet/sfc/ethtool_common.c     | 67 +++++++++---------
 drivers/net/ethernet/sfc/falcon/ethtool.c     | 68 +++++++++---------
 .../net/ethernet/sfc/siena/ethtool_common.c   | 69 +++++++++----------
 3 files changed, 99 insertions(+), 105 deletions(-)

diff --git a/drivers/net/ethernet/sfc/ethtool_common.c b/drivers/net/ethernet/sfc/ethtool_common.c
index 54f8e4626568..62a94c995241 100644
--- a/drivers/net/ethernet/sfc/ethtool_common.c
+++ b/drivers/net/ethernet/sfc/ethtool_common.c
@@ -247,18 +247,17 @@ int efx_ethtool_set_pauseparam(struct net_device *net_dev,
  * @strings:		Ethtool strings, or %NULL
  * @data:		Ethtool test results, or %NULL
  * @test:		Pointer to test result (used only if data != %NULL)
- * @unit_format:	Unit name format (e.g. "chan\%d")
- * @unit_id:		Unit id (e.g. 0 for "chan0")
+ * @unit_name:		Unit name
  * @test_format:	Test name format (e.g. "loopback.\%s.tx.sent")
- * @test_id:		Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
  *
  * Fill in an individual self-test entry.
  */
-static void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data,
-			  int *test, const char *unit_format, int unit_id,
-			  const char *test_format, const char *test_id)
+static void __printf(6, 7) efx_fill_test(unsigned int test_index, u8 *strings,
+					 u64 *data, int *test,
+					 const char *unit_name,
+					 const char *test_format, ...)
 {
-	char unit_str[ETH_GSTRING_LEN], test_str[ETH_GSTRING_LEN];
+	char test_str[ETH_GSTRING_LEN];
 
 	/* Fill data value, if applicable */
 	if (data)
@@ -266,20 +265,16 @@ static void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data,
 
 	/* Fill string, if applicable */
 	if (strings) {
-		if (strchr(unit_format, '%'))
-			snprintf(unit_str, sizeof(unit_str),
-				 unit_format, unit_id);
-		else
-			strcpy(unit_str, unit_format);
-		snprintf(test_str, sizeof(test_str), test_format, test_id);
+		va_list args;
+
+		va_start(args, test_format);
+		vsnprintf(test_str, sizeof(test_str), test_format, args);
+		va_end(args);
 		snprintf(strings + test_index * ETH_GSTRING_LEN,
-			 ETH_GSTRING_LEN,
-			 "%-6s %-24s", unit_str, test_str);
+			 ETH_GSTRING_LEN, "%-6s %-24s", unit_name, test_str);
 	}
 }
 
-#define EFX_CHANNEL_NAME(_channel) "chan%d", _channel->channel
-#define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->label
 #define EFX_LOOPBACK_NAME(_mode, _counter)			\
 	"loopback.%s." _counter, STRING_TABLE_LOOKUP(_mode, efx_loopback_mode)
 
@@ -306,23 +301,23 @@ static int efx_fill_loopback_test(struct efx_nic *efx,
 	struct efx_tx_queue *tx_queue;
 
 	efx_for_each_channel_tx_queue(tx_queue, channel) {
+		char unit_str[ETH_GSTRING_LEN];
+
+		snprintf(unit_str, sizeof(unit_str), "txq%d", tx_queue->label);
+
 		efx_fill_test(test_index++, strings, data,
 			      &lb_tests->tx_sent[tx_queue->label],
-			      EFX_TX_QUEUE_NAME(tx_queue),
-			      EFX_LOOPBACK_NAME(mode, "tx_sent"));
+			      unit_str, EFX_LOOPBACK_NAME(mode, "tx_sent"));
 		efx_fill_test(test_index++, strings, data,
 			      &lb_tests->tx_done[tx_queue->label],
-			      EFX_TX_QUEUE_NAME(tx_queue),
-			      EFX_LOOPBACK_NAME(mode, "tx_done"));
+			      unit_str, EFX_LOOPBACK_NAME(mode, "tx_done"));
 	}
 	efx_fill_test(test_index++, strings, data,
 		      &lb_tests->rx_good,
-		      "rx", 0,
-		      EFX_LOOPBACK_NAME(mode, "rx_good"));
+		      "rx", EFX_LOOPBACK_NAME(mode, "rx_good"));
 	efx_fill_test(test_index++, strings, data,
 		      &lb_tests->rx_bad,
-		      "rx", 0,
-		      EFX_LOOPBACK_NAME(mode, "rx_bad"));
+		      "rx", EFX_LOOPBACK_NAME(mode, "rx_bad"));
 
 	return test_index;
 }
@@ -349,28 +344,30 @@ int efx_ethtool_fill_self_tests(struct efx_nic *efx,
 	enum efx_loopback_mode mode;
 
 	efx_fill_test(n++, strings, data, &tests->phy_alive,
-		      "phy", 0, "alive", NULL);
+		      "phy", "alive");
 	efx_fill_test(n++, strings, data, &tests->nvram,
-		      "core", 0, "nvram", NULL);
+		      "core", "nvram");
 	efx_fill_test(n++, strings, data, &tests->interrupt,
-		      "core", 0, "interrupt", NULL);
+		      "core", "interrupt");
 
 	/* Event queues */
 	efx_for_each_channel(channel, efx) {
+		char unit_str[ETH_GSTRING_LEN];
+
+		snprintf(unit_str, sizeof(unit_str), "txq%d", channel->channel);
+
 		efx_fill_test(n++, strings, data,
 			      &tests->eventq_dma[channel->channel],
-			      EFX_CHANNEL_NAME(channel),
-			      "eventq.dma", NULL);
+			      unit_str, "eventq.dma");
 		efx_fill_test(n++, strings, data,
 			      &tests->eventq_int[channel->channel],
-			      EFX_CHANNEL_NAME(channel),
-			      "eventq.int", NULL);
+			      unit_str, "eventq.int");
 	}
 
 	efx_fill_test(n++, strings, data, &tests->memory,
-		      "core", 0, "memory", NULL);
+		      "core", "memory");
 	efx_fill_test(n++, strings, data, &tests->registers,
-		      "core", 0, "registers", NULL);
+		      "core", "registers");
 
 	for (i = 0; true; ++i) {
 		const char *name;
@@ -380,7 +377,7 @@ int efx_ethtool_fill_self_tests(struct efx_nic *efx,
 		if (name == NULL)
 			break;
 
-		efx_fill_test(n++, strings, data, &tests->phy_ext[i], "phy", 0, name, NULL);
+		efx_fill_test(n++, strings, data, &tests->phy_ext[i], "phy", "%s", name);
 	}
 
 	/* Loopback tests */
diff --git a/drivers/net/ethernet/sfc/falcon/ethtool.c b/drivers/net/ethernet/sfc/falcon/ethtool.c
index 807c587eba3b..260340b291d3 100644
--- a/drivers/net/ethernet/sfc/falcon/ethtool.c
+++ b/drivers/net/ethernet/sfc/falcon/ethtool.c
@@ -200,18 +200,17 @@ static void ef4_ethtool_set_msglevel(struct net_device *net_dev, u32 msg_enable)
  * @strings:		Ethtool strings, or %NULL
  * @data:		Ethtool test results, or %NULL
  * @test:		Pointer to test result (used only if data != %NULL)
- * @unit_format:	Unit name format (e.g. "chan\%d")
- * @unit_id:		Unit id (e.g. 0 for "chan0")
+ * @unit_name:		Unit name
  * @test_format:	Test name format (e.g. "loopback.\%s.tx.sent")
- * @test_id:		Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
  *
  * Fill in an individual self-test entry.
  */
-static void ef4_fill_test(unsigned int test_index, u8 *strings, u64 *data,
-			  int *test, const char *unit_format, int unit_id,
-			  const char *test_format, const char *test_id)
+static void __printf(6, 7) ef4_fill_test(unsigned int test_index, u8 *strings,
+					 u64 *data, int *test,
+					 const char *unit_name,
+					 const char *test_format, ...)
 {
-	char unit_str[ETH_GSTRING_LEN], test_str[ETH_GSTRING_LEN];
+	char test_str[ETH_GSTRING_LEN];
 
 	/* Fill data value, if applicable */
 	if (data)
@@ -219,21 +218,17 @@ static void ef4_fill_test(unsigned int test_index, u8 *strings, u64 *data,
 
 	/* Fill string, if applicable */
 	if (strings) {
-		if (strchr(unit_format, '%'))
-			snprintf(unit_str, sizeof(unit_str),
-				 unit_format, unit_id);
-		else
-			strcpy(unit_str, unit_format);
-		snprintf(test_str, sizeof(test_str), test_format, test_id);
+		va_list arg;
+
+		va_start(arg, test_format);
+		vsnprintf(test_str, sizeof(test_str), test_format, arg);
+		va_end(arg);
 		snprintf(strings + test_index * ETH_GSTRING_LEN,
 			 ETH_GSTRING_LEN,
-			 "%-6s %-24s", unit_str, test_str);
+			 "%-6s %-24s", unit_name, test_str);
 	}
 }
 
-#define EF4_CHANNEL_NAME(_channel) "chan%d", _channel->channel
-#define EF4_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue
-#define EF4_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue
 #define EF4_LOOPBACK_NAME(_mode, _counter)			\
 	"loopback.%s." _counter, STRING_TABLE_LOOKUP(_mode, ef4_loopback_mode)
 
@@ -260,23 +255,23 @@ static int ef4_fill_loopback_test(struct ef4_nic *efx,
 	struct ef4_tx_queue *tx_queue;
 
 	ef4_for_each_channel_tx_queue(tx_queue, channel) {
+		char unit_str[ETH_GSTRING_LEN];
+
+		snprintf(unit_str, sizeof(unit_str), "txq%d", tx_queue->queue);
+
 		ef4_fill_test(test_index++, strings, data,
 			      &lb_tests->tx_sent[tx_queue->queue],
-			      EF4_TX_QUEUE_NAME(tx_queue),
-			      EF4_LOOPBACK_NAME(mode, "tx_sent"));
+			      unit_str, EF4_LOOPBACK_NAME(mode, "tx_sent"));
 		ef4_fill_test(test_index++, strings, data,
 			      &lb_tests->tx_done[tx_queue->queue],
-			      EF4_TX_QUEUE_NAME(tx_queue),
-			      EF4_LOOPBACK_NAME(mode, "tx_done"));
+			      unit_str, EF4_LOOPBACK_NAME(mode, "tx_done"));
 	}
 	ef4_fill_test(test_index++, strings, data,
 		      &lb_tests->rx_good,
-		      "rx", 0,
-		      EF4_LOOPBACK_NAME(mode, "rx_good"));
+		      "rx", EF4_LOOPBACK_NAME(mode, "rx_good"));
 	ef4_fill_test(test_index++, strings, data,
 		      &lb_tests->rx_bad,
-		      "rx", 0,
-		      EF4_LOOPBACK_NAME(mode, "rx_bad"));
+		      "rx", EF4_LOOPBACK_NAME(mode, "rx_bad"));
 
 	return test_index;
 }
@@ -303,28 +298,31 @@ static int ef4_ethtool_fill_self_tests(struct ef4_nic *efx,
 	enum ef4_loopback_mode mode;
 
 	ef4_fill_test(n++, strings, data, &tests->phy_alive,
-		      "phy", 0, "alive", NULL);
+		      "phy", "alive");
 	ef4_fill_test(n++, strings, data, &tests->nvram,
-		      "core", 0, "nvram", NULL);
+		      "core", "nvram");
 	ef4_fill_test(n++, strings, data, &tests->interrupt,
-		      "core", 0, "interrupt", NULL);
+		      "core", "interrupt");
 
 	/* Event queues */
 	ef4_for_each_channel(channel, efx) {
+		char unit_str[ETH_GSTRING_LEN];
+
+		snprintf(unit_str, sizeof(unit_str), "chan%d",
+			 channel->channel);
+
 		ef4_fill_test(n++, strings, data,
 			      &tests->eventq_dma[channel->channel],
-			      EF4_CHANNEL_NAME(channel),
-			      "eventq.dma", NULL);
+			      unit_str, "eventq.dma");
 		ef4_fill_test(n++, strings, data,
 			      &tests->eventq_int[channel->channel],
-			      EF4_CHANNEL_NAME(channel),
-			      "eventq.int", NULL);
+			      unit_str, "eventq.int");
 	}
 
 	ef4_fill_test(n++, strings, data, &tests->memory,
-		      "core", 0, "memory", NULL);
+		      "core", "memory");
 	ef4_fill_test(n++, strings, data, &tests->registers,
-		      "core", 0, "registers", NULL);
+		      "core", "registers");
 
 	if (efx->phy_op->run_tests != NULL) {
 		EF4_BUG_ON_PARANOID(efx->phy_op->test_name == NULL);
@@ -338,7 +336,7 @@ static int ef4_ethtool_fill_self_tests(struct ef4_nic *efx,
 				break;
 
 			ef4_fill_test(n++, strings, data, &tests->phy_ext[i],
-				      "phy", 0, name, NULL);
+				      "phy", "%s", name);
 		}
 	}
 
diff --git a/drivers/net/ethernet/sfc/siena/ethtool_common.c b/drivers/net/ethernet/sfc/siena/ethtool_common.c
index 76cbce2b9592..e49cc604b43a 100644
--- a/drivers/net/ethernet/sfc/siena/ethtool_common.c
+++ b/drivers/net/ethernet/sfc/siena/ethtool_common.c
@@ -199,18 +199,17 @@ int efx_siena_ethtool_set_pauseparam(struct net_device *net_dev,
  * @strings:		Ethtool strings, or %NULL
  * @data:		Ethtool test results, or %NULL
  * @test:		Pointer to test result (used only if data != %NULL)
- * @unit_format:	Unit name format (e.g. "chan\%d")
- * @unit_id:		Unit id (e.g. 0 for "chan0")
+ * @unit_name:		Unit name
  * @test_format:	Test name format (e.g. "loopback.\%s.tx.sent")
- * @test_id:		Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
  *
  * Fill in an individual self-test entry.
  */
-static void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data,
-			  int *test, const char *unit_format, int unit_id,
-			  const char *test_format, const char *test_id)
+static void __printf(6, 7) efx_fill_test(unsigned int test_index, u8 *strings,
+					 u64 *data, int *test,
+					 const char *unit_name,
+					 char *test_format, ...)
 {
-	char unit_str[ETH_GSTRING_LEN], test_str[ETH_GSTRING_LEN];
+	char test_str[ETH_GSTRING_LEN];
 
 	/* Fill data value, if applicable */
 	if (data)
@@ -218,20 +217,16 @@ static void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data,
 
 	/* Fill string, if applicable */
 	if (strings) {
-		if (strchr(unit_format, '%'))
-			snprintf(unit_str, sizeof(unit_str),
-				 unit_format, unit_id);
-		else
-			strcpy(unit_str, unit_format);
-		snprintf(test_str, sizeof(test_str), test_format, test_id);
+		va_list args;
+
+		va_start(args, test_format);
+		vsnprintf(test_str, sizeof(test_str), test_format, args);
+		va_end(args);
 		snprintf(strings + test_index * ETH_GSTRING_LEN,
-			 ETH_GSTRING_LEN,
-			 "%-6s %-24s", unit_str, test_str);
+			 ETH_GSTRING_LEN, "%-6s %-24s", unit_name, test_str);
 	}
 }
 
-#define EFX_CHANNEL_NAME(_channel) "chan%d", _channel->channel
-#define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->label
 #define EFX_LOOPBACK_NAME(_mode, _counter)			\
 	"loopback.%s." _counter, STRING_TABLE_LOOKUP(_mode, efx_siena_loopback_mode)
 
@@ -258,23 +253,23 @@ static int efx_fill_loopback_test(struct efx_nic *efx,
 	struct efx_tx_queue *tx_queue;
 
 	efx_for_each_channel_tx_queue(tx_queue, channel) {
+		char unit_str[ETH_GSTRING_LEN];
+
+		snprintf(unit_str, sizeof(unit_str), "txq%d",tx_queue->label);
+
 		efx_fill_test(test_index++, strings, data,
 			      &lb_tests->tx_sent[tx_queue->label],
-			      EFX_TX_QUEUE_NAME(tx_queue),
-			      EFX_LOOPBACK_NAME(mode, "tx_sent"));
+			      unit_str, EFX_LOOPBACK_NAME(mode, "tx_sent"));
 		efx_fill_test(test_index++, strings, data,
 			      &lb_tests->tx_done[tx_queue->label],
-			      EFX_TX_QUEUE_NAME(tx_queue),
-			      EFX_LOOPBACK_NAME(mode, "tx_done"));
+			      unit_str, EFX_LOOPBACK_NAME(mode, "tx_done"));
 	}
 	efx_fill_test(test_index++, strings, data,
 		      &lb_tests->rx_good,
-		      "rx", 0,
-		      EFX_LOOPBACK_NAME(mode, "rx_good"));
+		      "rx", EFX_LOOPBACK_NAME(mode, "rx_good"));
 	efx_fill_test(test_index++, strings, data,
 		      &lb_tests->rx_bad,
-		      "rx", 0,
-		      EFX_LOOPBACK_NAME(mode, "rx_bad"));
+		      "rx", EFX_LOOPBACK_NAME(mode, "rx_bad"));
 
 	return test_index;
 }
@@ -301,28 +296,31 @@ static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
 	enum efx_loopback_mode mode;
 
 	efx_fill_test(n++, strings, data, &tests->phy_alive,
-		      "phy", 0, "alive", NULL);
+		      "phy", "alive");
 	efx_fill_test(n++, strings, data, &tests->nvram,
-		      "core", 0, "nvram", NULL);
+		      "core", "nvram");
 	efx_fill_test(n++, strings, data, &tests->interrupt,
-		      "core", 0, "interrupt", NULL);
+		      "core", "interrupt");
 
 	/* Event queues */
 	efx_for_each_channel(channel, efx) {
+		char unit_str[ETH_GSTRING_LEN];
+
+		snprintf(unit_str, sizeof(unit_str), "chan%d",
+			 channel->channel);
+
 		efx_fill_test(n++, strings, data,
 			      &tests->eventq_dma[channel->channel],
-			      EFX_CHANNEL_NAME(channel),
-			      "eventq.dma", NULL);
+			      unit_str, "eventq.dma");
 		efx_fill_test(n++, strings, data,
 			      &tests->eventq_int[channel->channel],
-			      EFX_CHANNEL_NAME(channel),
-			      "eventq.int", NULL);
+			      unit_str, "eventq.int");
 	}
 
 	efx_fill_test(n++, strings, data, &tests->memory,
-		      "core", 0, "memory", NULL);
+		      "core", "memory");
 	efx_fill_test(n++, strings, data, &tests->registers,
-		      "core", 0, "registers", NULL);
+		      "core", "registers");
 
 	for (i = 0; true; ++i) {
 		const char *name;
@@ -332,7 +330,8 @@ static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
 		if (name == NULL)
 			break;
 
-		efx_fill_test(n++, strings, data, &tests->phy_ext[i], "phy", 0, name, NULL);
+		efx_fill_test(n++, strings, data, &tests->phy_ext[i], "phy",
+			      "%s", name);
 	}
 
 	/* Loopback tests */
-- 
2.39.5


From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id C44801D9A54
	for <linux-kernel@vger.kernel.org>; Thu, 26 Mar 2026 02:00:27 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48
ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1774490429; cv=none; b=GmkyPuPEHcGqt+AbO25tS0/5brOEZiloaUpIk1uTr92HitseJBg/3oHYUOIi9zGE6sne0OHPzeullbP3CXfGUt21/91LasvvrcZqwrnyXeO/xFsqyzWmxnFM32hiIkuh9Ej+NFnsXU1k009RyV1cQmYYMhxRBVFUgvuMzCgXRwM=
ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1774490429; c=relaxed/simple;
	bh=RfijQGsKWUEkGdgHfWsVT1ZhVP2PeputQJ9VXpu31nw=;
	h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:
	 In-Reply-To:Content-Type; b=d1DRtq8Q6jqyETgVHhJU5obwsTAxMwaeu8BxYzufgWynl/49wfGeKugJZo9mUFd9sk+Zglcsd79OihnGohLCo+6YGil/8hn2bUhbhBnFTEaQo0ZyNCD5aCQsFowwanBluAdgCAi6rGCnigNcUAYYjRgFUa+or2Djs7dJd03NqQw=
ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jpj5ctjF; arc=none smtp.client-ip=209.85.128.48
Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jpj5ctjF"
Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4852b81c73aso4184005e9.3
        for <linux-kernel@vger.kernel.org>; Wed, 25 Mar 2026 19:00:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1774490426; x=1775095226; darn=vger.kernel.org;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:cc:to:subject:user-agent:mime-version:date:message-id
         :from:to:cc:subject:date:message-id:reply-to;
        bh=uhbkdLidpODGTRsYmLRF0FS3n+wDOfvaXSzlGywSvfg=;
        b=jpj5ctjFPZaj9H6LLVDzUgyNEThHIOeQvBsaFa7xuuWc3a/lWsuUZhEmiKb8gnLAeW
         KE3eLRRD2yAOdLM4dm2Zgb2ozn4NvRNsWk1WlTr9opooe8wDD9DzuHHDUbUUCFrV1FKh
         5SSqoRvP8M2IyqN8Sn7zy/ttnrD7eqsksxRElhtQvStAGAkXUdmk+VKYXJZpsOXnPzu4
         rjMzxrfxj+zAI+FQfkxTW2IsrGz8Aqt9N4dazhq6kGv+QVVbYilPio1j7R0PFTyaiScH
         o87zC8Es2llo2IjIjd/AmTkWr2jKGoMeof/8E8iQ8UDRtvNPf8fGYrP7bSPFg1tQgv9x
         +Z2g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20251104; t=1774490426; x=1775095226;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:cc:to:subject:user-agent:mime-version:date:message-id
         :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=uhbkdLidpODGTRsYmLRF0FS3n+wDOfvaXSzlGywSvfg=;
        b=P8aLhU0cE+pMVeGs2+DV3w5ckMNb0ywnc+3wcTfxEJt5OV45ng0vxF13Fouz3skZzg
         tb2N84Yg4JDimJnxjq8V2piEozyOSS099S2OqXBKn4TynqK6iYZgjFaYobqhO9R75Jz+
         79p69O5WtiF6S8vAuLR2qSOqLECAZbScO8oZ0kP3djhN1i5ZbNh7DTYFlIjVdh+WC6e5
         yRH2baGedWD6zed+im1UzToHYwVIiLTQLWiDrPLN5zgKdMuIXTAuCjAAnIuJjubQOJO6
         22U77HjZDclkpU9NH6Cv4A6lAXnl/VOp/hza4kyMfSo1WMgfSkdqnH+y0kDHVGqHZinT
         5Xdw==
X-Forwarded-Encrypted: i=1; AJvYcCWErR05CxO2hRNcfJE36nc5ihKhDAF+CvMDC9Cm8FPasUaNWncL7yozN5wTlC8BRb2l2tSCEZvpLkyl0ew=@vger.kernel.org
X-Gm-Message-State: AOJu0YyjHKhLil8tUPOrwQFLY4RU4Gm5u/6xiYJNwuXne34joLo8BJ6E
	AFh7MNusLt0OoARRRlQrmg/49O0EmEjo9sb2AzH07Ge/MDzA29yRG/J4
X-Gm-Gg: ATEYQzxGLWJ0os+AWdb6bjGvW0oktiRojVZqvWxMefTKQVioGy5N785W8DBu2tRo3xz
	uN8qCgQHgaQj5rG1avh478ZvieDhDJuxCm4bKRjHR+fOeHHfRkYxVGW0lJ8GClmhVHo3zMHtXSn
	C4SXJLrWOVcIAUSnah017VYCdBc8nKkhf1urLsES9+v8ADZKfSXzV2DJIhWpFHrdyE4iLBkFfcH
	E/yctQwcef35r6BNsFp9zl+QkbzUsv/JAIx4q9loe0FrQGjDZPVtlzoJDBJvDwYzoXATV3PJ8eX
	fRTnN0UdhUTMkHkPXu/n8vBpQynZESS/VyZDJoYF6ATXItbXj4bItslMkLt9GaDR1lQ/gZlHjbR
	hfmXh2zSACkdyFrCq8IqNSJPk1Qx+6RtVauMfXn75xRQ/8Nz97WfYknLSUEi5XNhPvJAtQh82qf
	qtCgXc0QreJDZbg6ZlSynQ+qiMvEMV5D5kMW1C4Y4UfjDybBU5H9Ii7MqRA3XR+Bs395rJ9oEo/
	17teKsiZ5mzdA==
X-Received: by 2002:a05:600c:c4a6:b0:485:3dfc:57c with SMTP id 5b1f17b1804b1-48716042c15mr81428365e9.21.1774490425914;
        Wed, 25 Mar 2026 19:00:25 -0700 (PDT)
Received: from [192.168.1.122] (cpc159313-cmbg20-2-0-cust161.5-4.cable.virginm.net. [82.0.78.162])
        by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4871fb333fbsm33300625e9.3.2026.03.25.19.00.23
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Wed, 25 Mar 2026 19:00:24 -0700 (PDT)
Message-ID: <fab5260a-b83f-4750-8b4e-ae5c1313d7ba@gmail.com>
Date: Thu, 26 Mar 2026 02:00:23 +0000
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [PATCH] [v2] net: sfc: avoid format string warning
To: Arnd Bergmann <arnd@kernel.org>, Andrew Lunn <andrew+netdev@lunn.ch>,
 "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>,
 Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
 Nathan Chancellor <nathan@kernel.org>, Jeff Garzik <jgarzik@redhat.com>,
 Ben Hutchings <bhutchings@solarflare.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
 Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
 Bill Wendling <morbo@google.com>, Justin Stitt <justinstitt@google.com>,
 Brett Creeley <brett.creeley@amd.com>, Breno Leitao <leitao@debian.org>,
 Kees Cook <kees@kernel.org>, netdev@vger.kernel.org,
 linux-net-drivers@amd.com, linux-kernel@vger.kernel.org, llvm@lists.linux.dev
References: <20260325134557.3406655-1-arnd@kernel.org>
Content-Language: en-GB
From: Edward Cree <ecree.xilinx@gmail.com>
In-Reply-To: <20260325134557.3406655-1-arnd@kernel.org>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

On 25/03/2026 13:45, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Three sfc drivers contain the same *_fill_test() function that takes
> a format string argument that gets passed down to snprintf(), producing
> a warning with clang-22:
> 
> drivers/net/ethernet/sfc/falcon/ethtool.c:227:60: error: diagnostic behavior may be improved by adding
>       the 'format(printf, 7, 8)' attribute to the declaration of 'ef4_fill_test' [-Werror,-Wmissing-format-attribute]
>   210 |                 snprintf(test_str, sizeof(test_str), test_format, test_id);
>       |                                                                          ^
> drivers/net/ethernet/sfc/falcon/ethtool.c:210:13: note: 'ef4_fill_test' declared here
> 
> Rework these to take a varargs based test_format that allows better
> type checking and a non-varargs unit name that gets pre-filled by
> the caller, so that the compiler can validate all format strings.
> 
> Fixes: 3273c2e8c66a ("[netdrvr] sfc: sfc: Add self-test support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>

From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id E70DA314B84;
	Thu, 26 Mar 2026 09:18:30 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108
ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1774516712; cv=none; b=ecY7nu+rqdUW/gwwHSBGAyEkgSJaTBKX6WDDNk+SFIqnnKn8Z/mS+YMdeeZguy2yu1bf3gWJE2+m0xjAYiAZ11+YxhRfpT09u1qXZpyK089Yl7ml6kKHZ4GHVS1T3Ahn32ELef4gCcdbD0CHwg6ncnxoafgV0g3PBWJnVMhII2Q=
ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1774516712; c=relaxed/simple;
	bh=vvbrnA0+898pMRQlJ9PQpXwM80nzyirRDqrs56qTSnU=;
	h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:
	 Content-Type:Content-Disposition:In-Reply-To; b=IPNw4tt+aqfZZClA3xGOvcretFChp0RsJk+XNfIW90RUEsdAaF4+MK4amRQNrlAHXW7iBghyELuFjltFPMJWeyQj8J0n9hDgfLkIL8A0VjpRLRD+Hf7Oli3XeLkIXG5EvJ1Mwx/8OIkCjp3TybMBgcOlHRbwYKw7MDAdehXpXho=
ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=none smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=U53i+EXs; arc=none smtp.client-ip=82.195.75.108
Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org
Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=debian.org
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="U53i+EXs"
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org;
	s=smtpauto.stravinsky; h=X-Debian-User:In-Reply-To:Content-Type:MIME-Version:
	References:Message-ID:Subject:Cc:To:From:Date:Reply-To:
	Content-Transfer-Encoding:Content-ID:Content-Description;
	bh=rQFc9TaMPa+MJvbas5O7gxSnkgSoNa81YzdAVy0iL4c=; b=U53i+EXs40w+2RO57CuIxtBEvV
	a/eRL+yyV0sDg9RwSPdxSOhWmisdR/bATD35Kt8IINksMi/rAsAM3OqpKqSh2BdSrGh9/yXAW1lNj
	ECWxn6jsWNeQGKPPF1nh5sOR0iEr2bIdDOWqrX16OblKuRWeHdDwAMouYC9Zgqt8tJKkxwGX1OCpd
	nxedaaxfHgGH3eWjsXG8/qKWcJtMdbRtRm3X/5nOhGZNSne9OsVFQVU4ostMuxSbD3+saAXpvy47e
	4T2Q7g+QjQn5EhrZfJwtTbMXly46uzJAz6PKtTgZsa9NbOUPniFdl0+uTFDgmlho2Rb/jysly+buX
	lyU3lV/A==;
Received: from authenticated user
	by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)
	(Exim 4.94.2)
	(envelope-from <leitao@debian.org>)
	id 1w5gqr-009kHn-V9; Thu, 26 Mar 2026 09:18:06 +0000
Date: Thu, 26 Mar 2026 02:17:59 -0700
From: Breno Leitao <leitao@debian.org>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Edward Cree <ecree.xilinx@gmail.com>, 
	Andrew Lunn <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>, 
	Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, 
	Paolo Abeni <pabeni@redhat.com>, Nathan Chancellor <nathan@kernel.org>, 
	Jeff Garzik <jgarzik@redhat.com>, Ben Hutchings <bhutchings@solarflare.com>, 
	Arnd Bergmann <arnd@arndb.de>, Nick Desaulniers <nick.desaulniers+lkml@gmail.com>, 
	Bill Wendling <morbo@google.com>, Justin Stitt <justinstitt@google.com>, 
	Brett Creeley <brett.creeley@amd.com>, Kees Cook <kees@kernel.org>, netdev@vger.kernel.org, 
	linux-net-drivers@amd.com, linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] [v2] net: sfc: avoid format string warning
Message-ID: <acT4fg86n7kpdm8e@gmail.com>
References: <20260325134557.3406655-1-arnd@kernel.org>
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id: <linux-kernel.vger.kernel.org>
List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20260325134557.3406655-1-arnd@kernel.org>
X-Debian-User: leitao

On Wed, Mar 25, 2026 at 02:45:44PM +0100, Arnd Bergmann wrote:
>  	/* Event queues */
>  	efx_for_each_channel(channel, efx) {
> +		char unit_str[ETH_GSTRING_LEN];
> +
> +		snprintf(unit_str, sizeof(unit_str), "txq%d", channel->channel);

The original EFX_CHANNEL_NAME macro expanded to "chan%d", didn't it?.
Shouldn't replace txq by chan in the line above?

		snprintf(unit_str, sizeof(unit_str), "chan%d", channel->channel);

> @@ -258,23 +253,23 @@ static int efx_fill_loopback_test(struct efx_nic *efx,
>  	struct efx_tx_queue *tx_queue;
>  
>  	efx_for_each_channel_tx_queue(tx_queue, channel) {
> +		char unit_str[ETH_GSTRING_LEN];
> +
> +		snprintf(unit_str, sizeof(unit_str), "txq%d",tx_queue->label);

You probably want a space after the comma here:

		snprintf(unit_str, sizeof(unit_str), "txq%d", tx_queue->label);

