#DEFINE LENGTH 4096
warning: ‘/name0’ directive output may be truncated writing 10 bytes into a region
of size between 1 and 4096 [-Wformat-truncation=]
snprintf(head_list->cname, LENGTH, "%s/name0", cpath);
^~~~~~~~~~
gcc is throwing this warning. How to fix this without using -Wformat-truncation= option?
cpath is a character with 4096 size
As
cpathcan be maximum 4096 characters long, appending/name0to the end of it inherently create a string that can be longer than 4096 characters and can't fit intohead_list->cnameIf you're sure that
cpathcan't be longer than 4090 characters then tell gcc to turn off warning for that specific line