Re: [PATCH] net: sfc: avoid format string warning

From: Kees Cook

Date: Fri Mar 20 2026 - 14:04:50 EST


On Fri, Mar 20, 2026 at 04:19:16PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> 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 avoids this warning.
>
> Fixes: 3273c2e8c66a ("[netdrvr] sfc: sfc: Add self-test support")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>

Nice rework!

Reviewed-by: Kees Cook <kees@xxxxxxxxxx>

--
Kees Cook