On Wed, Jan 10, 2018 at 10:30:15PM +0100, Arnd Bergmann wrote: > This warning option appears to be particularly good in finding code that > is actually dangerous in case of an overflow, and generally using > strscpy() improves either correctness and readability over strncpy(), > I think it's worth leaving enabled globally. > > I have an experimental patch series to let you wrap the _Pragma("GCC > diagnostic ingnored \"-Wstringop-truncation\"") directive in some > nicer syntax. Would that work for you here? Having a Pragma which silences errors is certainly better than nothing, but what might be nice is to have a way of tagging a variable or structure member function as "not guaranteed to be null terminated". That would suppress warnings where strncpy is used to set the character array, and add warnings if how the character array is accessed without taking due care that it might not be null-terminated. Essentially all of the on-disk strings in ext4 are not NUL terminated (or not necessarily NUL terminated). We either use an explicit length (directory entries) or we use a fixed length character array (for the things like the volume label, last error function, etc.) Cheers, - Ted