Re: [PATCH] net: macb: Truncate TX1519CNT for trailing NUL
From: Andrew Lunn
Date: Tue Mar 11 2025 - 10:12:25 EST
On Mon, Mar 10, 2025 at 03:24:16PM -0700, Kees Cook wrote:
> GCC 15's -Wunterminated-string-initialization saw that this string was
> being truncated. Adjust the initializer so that the needed final NUL
> character will be present.
This is where we get into the ugliness of the ethtool API for strings.
It is not actually NUL terminated. The code uses memcpy(), see:
https://elixir.bootlin.com/linux/v6.13.6/source/drivers/net/ethernet/cadence/macb_main.c#L3193
The kAPI is that userspace provides a big buffer, and the kernel then
copies these strings into the buffer at 32 byte offsets. There is no
requirement for a NUL between them since they are all 32 bytes long.
Andrew