Martin Husemann writes: > On Sat, Mar 16, 2019 at 10:18:48AM +0000, Chavdar Ivanov wrote: > > xenpmd.c: In function 'get_next_battery_file': > > xenpmd.c:90:36: error: '%s' directive output may be truncated writing > > up to 511 bytes into a region of size 271 [-Werror=format-truncation=] > > #define BATTERY_INFO_FILE_PATH "/tmp/battery/%s/info" > > ^ > > xenpmd.c:113:52: note: in expansion of macro 'BATTERY_INFO_FILE_PATH' > > snprintf(file_name, sizeof(file_name), BATTERY_INFO_FILE_PATH, > > ^~~~~~~~~~~~~~~~~~~~~~ > > xenpmd.c:113:13: note: 'snprintf' output between 19 and 530 bytes into > > a destination of size 284 > > snprintf(file_name, sizeof(file_name), BATTERY_INFO_FILE_PATH, > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > dir_entries->d_name); > > ~~~~~~~~~~~~~~~~~~~~ > > IMO the most stupid warning ever added to gcc. I would just disable it for > newer gcc.
i don't agree. some times it is very difficult to avoid and it sometimes misdiagnoses the problem but it found a couple of dozen real bugs where user input would lead to segv, so it has clear value in my mind. .mrg.