Re: [PATCH] tools/thermal/tmon: Fix string truncation warning in optarg copy
From: Daniel Lezcano
Date: Wed Oct 07 2026 - 09:41:36 EST
On 9/29/26 22:19, Florian Fainelli wrote:
GCC warns about possible string truncation with -Wstringop-truncation:Applied, thanks
tmon.c: In function ‘main’:
tmon.c:233:25: warning: ‘__builtin_strncpy’ specified bound 20 equals
destination size [-Wstringop-truncation]
233 | strncpy(ctrl_cdev, optarg,
CDEV_NAME_SIZE);
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Replace strncpy() with snprintf() to guarantee NUL-termination and
silence the compiler warning.
Fixes: 94f69966faf8 ("tools/thermal: Introduce tmon, a tool for thermal subsystem")
Signed-off-by: Florian Fainelli <florian.fainelli@xxxxxxxxxxxx>
---