On Tue, Jan 9, 2018 at 9:20 PM, Theodore Ts'o <tytso@xxxxxxx> wrote: > On Tue, Jan 09, 2018 at 07:14:36PM +0800, Xiongfeng Wang wrote: >> >> Sorry, I didn't notice how s_last_error_func is used before. >> We do waste one character if we use strlcpy() instead of strncpy(). >> We can't use memcpy() either. But I can't figure out a better way to avoid >> this warning. > > Compain to the GCC developers? Create scripts that filter out crap? 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? Arnd