On Sat, 23 Sep 2023 09:15:38 +0200, Christophe JAILLET wrote: > In order to teach the compiler that 'trig->name' will never be truncated, > we need to tell it that 'cpu' is not negative. > > When building with W=1, this fixes the following warnings: > > drivers/leds/trigger/ledtrig-cpu.c: In function ‘ledtrig_cpu_init’: > drivers/leds/trigger/ledtrig-cpu.c:155:56: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 5 [-Werror=format-truncation=] > 155 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); > | ^~ > drivers/leds/trigger/ledtrig-cpu.c:155:52: note: directive argument in the range [-2147483648, 7] > 155 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); > | ^~~~~~~ > drivers/leds/trigger/ledtrig-cpu.c:155:17: note: ‘snprintf’ output between 5 and 15 bytes into a destination of size 8 > 155 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > [...] Applied, thanks! [1/1] leds: trigger: ledtrig-cpu:: Fix a warning when compiling with W=1 commit: 5272d74b29929c8395720a7e35971a4f0fb6783d -- Lee Jones [李琼斯]