From: Simon Horman <horms@kernel.org>
To: Alok Tiwari <alok.a.tiwari@oracle.com>
Cc: sgoutham@marvell.com, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
darren.kenny@oracle.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2] net: thunderx: Fix format-truncation warning in bgx_acpi_match_id()
Date: Wed, 9 Jul 2025 11:08:26 +0100 [thread overview]
Message-ID: <20250709100826.GT452973@horms.kernel.org> (raw)
In-Reply-To: <20250708175250.2090112-1-alok.a.tiwari@oracle.com>
On Tue, Jul 08, 2025 at 10:52:43AM -0700, Alok Tiwari wrote:
> The buffer bgx_sel used in snprintf() was too small to safely hold
> the formatted string "BGX%d" for all valid bgx_id values. This caused
> a -Wformat-truncation warning with Werror enabled during build.
>
> Increase the buffer size from 5 to 8 and use sizeof(bgx_sel) in
> snprintf() to ensure safety and suppress the warning.
>
> Build warning:
> CC drivers/net/ethernet/cavium/thunder/thunder_bgx.o
> drivers/net/ethernet/cavium/thunder/thunder_bgx.c: In function
> ‘bgx_acpi_match_id’:
> drivers/net/ethernet/cavium/thunder/thunder_bgx.c:1434:27: error: ‘%d’
> directive output may be truncated writing between 1 and 3 bytes into a
> region of size 2 [-Werror=format-truncation=]
> snprintf(bgx_sel, 5, "BGX%d", bgx->bgx_id);
> ^~
> drivers/net/ethernet/cavium/thunder/thunder_bgx.c:1434:23: note:
> directive argument in the range [0, 255]
> snprintf(bgx_sel, 5, "BGX%d", bgx->bgx_id);
> ^~~~~~~
> drivers/net/ethernet/cavium/thunder/thunder_bgx.c:1434:2: note:
> ‘snprintf’ output between 5 and 7 bytes into a destination of size 5
> snprintf(bgx_sel, 5, "BGX%d", bgx->bgx_id);
>
> compiler warning due to insufficient snprintf buffer size.
>
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
> ---
> v1->v2
> No changes. Targeting for net-next.
> https://lore.kernel.org/all/20250708160957.GQ452973@horms.kernel.org/
Thanks for the update.
Reviewed-by: Simon Horman <horms@kernel.org>
next prev parent reply other threads:[~2025-07-09 11:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 17:52 [PATCH net-next v2] net: thunderx: Fix format-truncation warning in bgx_acpi_match_id() Alok Tiwari
2025-07-09 10:08 ` Simon Horman [this message]
2025-07-10 22:34 ` Jakub Kicinski
2025-07-11 10:17 ` ALOK TIWARI
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=20250709100826.GT452973@horms.kernel.org \
--to=horms@kernel.org \
--cc=alok.a.tiwari@oracle.com \
--cc=andrew+netdev@lunn.ch \
--cc=darren.kenny@oracle.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sgoutham@marvell.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.