linux/drivers/net/ethernet/cavium/thunder
Alok Tiwari 53d20606c4 net: thunderx: Fix format-truncation warning in bgx_acpi_match_id()
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 7 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>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250711140532.2463602-1-alok.a.tiwari@oracle.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-07-14 17:16:10 -07:00
..
Makefile
nic.h
nic_main.c
nic_reg.h
nicvf_ethtool.c eth: thunder: migrate to new RXFH callbacks 2025-06-18 13:17:47 -07:00
nicvf_main.c net: thunderx: avoid direct MTU assignment after WRITE_ONCE() 2025-07-09 19:12:07 -07:00
nicvf_queues.c net: thunder: make tx software timestamp independent 2025-05-09 16:21:25 -07:00
nicvf_queues.h
q_struct.h
thunder_bgx.c net: thunderx: Fix format-truncation warning in bgx_acpi_match_id() 2025-07-14 17:16:10 -07:00
thunder_bgx.h
thunder_xcv.c