On. 14 Sep. 2023 at 17:27, Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote: > Hello Vincent, > > when compiling the etas driver with gcc version 13.2.0 (Debian > 13.2.0-2) and W=1, it fails with: > > | drivers/net/can/usb/etas_es58x/es58x_devlink.c: In function ‘es58x_devlink_info_get’: > | drivers/net/can/usb/etas_es58x/es58x_devlink.c:201:55: error: ‘%02u’ directive output may be truncated writing between 2 and 3 bytes into a region of size between 1 and 3 [-Werror=format-truncation=] Actually, I was aware of that format-truncation warning, c.f. this message I wrote during the patch review: https://lore.kernel.org/all/CAMZ6Rq+K+6gbaZ35SOJcR9qQaTJ7KR0jW=XoDKFkobjhj8CHhw@xxxxxxxxxxxxxx/ What I did not anticipate is that the -Wformat-truncation would be re-introduced in: https://git.kernel.org/torvalds/p/6d4ab2e97dcf > | 201 | snprintf(buf, sizeof(buf), "%02u.%02u.%02u", > | | ^~~~ > | drivers/net/can/usb/etas_es58x/es58x_devlink.c:201:44: note: directive argument in the range [0, 255] > | 201 | snprintf(buf, sizeof(buf), "%02u.%02u.%02u", > | | ^~~~~~~~~~~~~~~~ > | drivers/net/can/usb/etas_es58x/es58x_devlink.c:201:17: note: ‘snprintf’ output between 9 and 12 bytes into a destination of size 9 > | 201 | snprintf(buf, sizeof(buf), "%02u.%02u.%02u", > | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | 202 | fw_ver->major, fw_ver->minor, fw_ver->revision); > | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | drivers/net/can/usb/etas_es58x/es58x_devlink.c:211:55: error: ‘%02u’ directive output may be truncated writing between 2 and 3 bytes into a region of size between 1 and 3 [-Werror=format-truncation=] > | 211 | snprintf(buf, sizeof(buf), "%02u.%02u.%02u", > | | ^~~~ > | drivers/net/can/usb/etas_es58x/es58x_devlink.c:211:44: note: directive argument in the range [0, 255] > | 211 | snprintf(buf, sizeof(buf), "%02u.%02u.%02u", > | | ^~~~~~~~~~~~~~~~ > | drivers/net/can/usb/etas_es58x/es58x_devlink.c:211:17: note: ‘snprintf’ output between 9 and 12 bytes into a destination of size 9 > | 211 | snprintf(buf, sizeof(buf), "%02u.%02u.%02u", > | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | 212 | bl_ver->major, bl_ver->minor, bl_ver->revision); > | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | drivers/net/can/usb/etas_es58x/es58x_devlink.c:221:52: error: ‘%03u’ directive output may be truncated writing between 3 and 5 bytes into a region of size between 2 and 4 [-Werror=format-truncation=] > | 221 | snprintf(buf, sizeof(buf), "%c%03u/%03u", > | | ^~~~ > | drivers/net/can/usb/etas_es58x/es58x_devlink.c:221:44: note: directive argument in the range [0, 65535] > | 221 | snprintf(buf, sizeof(buf), "%c%03u/%03u", > | | ^~~~~~~~~~~~~ > | drivers/net/can/usb/etas_es58x/es58x_devlink.c:221:17: note: ‘snprintf’ output between 9 and 13 bytes into a destination of size 9 > | 221 | snprintf(buf, sizeof(buf), "%c%03u/%03u", > | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | 222 | hw_rev->letter, hw_rev->major, hw_rev->minor); > | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | cc1: all warnings being treated as errors > > Can you create a fix? Sure! This is not an actual bug but I like to keep my driver clean of any W=12 drivers. Yours sincerely, Vincent Mailhol