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>, Arnd Bergmann <arnd@arndb.de>,
Ben Hutchings <ben@decadent.org.uk>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.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: [net-next] [v3] net: sfc: avoid format string warning
Date: Tue, 2 Jun 2026 07:39:26 -0700 [thread overview]
Message-ID: <ah7qyOv2aCAOIKO8@gmail.com> (raw)
In-Reply-To: <20260602135347.3179200-1-arnd@kernel.org>
On Tue, Jun 02, 2026 at 03:53:04PM +0200, 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")
> Link: https://lore.kernel.org/all/20260325134557.3406655-1-arnd@kernel.org/
> Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
> Cc: Breno Leitao <leitao@debian.org>
> Cc: Ben Hutchings <ben@decadent.org.uk>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Breno Leitao <leitao@debian.org>
> diff --git a/drivers/net/ethernet/sfc/siena/ethtool_common.c b/drivers/net/ethernet/sfc/siena/ethtool_common.c
> index 76cbce2b9592..9df08f1e2347 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, ...)
Should you keep the 'const' in test_format?
prev parent reply other threads:[~2026-06-02 14:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 13:53 [net-next] [v3] net: sfc: avoid format string warning Arnd Bergmann
2026-06-02 14:39 ` Breno Leitao [this message]
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=ah7qyOv2aCAOIKO8@gmail.com \
--to=leitao@debian.org \
--cc=andrew+netdev@lunn.ch \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=ben@decadent.org.uk \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-net-drivers@amd.com \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=pabeni@redhat.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