[lkml]   [2018]   [Aug]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: linux-next: build warnings from Linus' tree
On Mon, Aug 20, 2018 at 08:13:23AM +1000, Stephen Rothwell wrote:
> fs/ext4/super.c: In function '__save_error_info':
> fs/ext4/super.c:344:2: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
> strncpy(es->s_last_error_func, func, sizeof(es->s_last_error_func));
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> fs/ext4/super.c:349:3: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
> strncpy(es->s_first_error_func, func,
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> sizeof(es->s_first_error_func));
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All of ext4 superblock char[] fields are not necessarily null
terminated, so this is a false positive. I suppose we could do
something like this:

inline char *
strncpy_I_solemnly_swear_I_know_what_I_am_doing(char *dest,
const char *src, size_t n)
#if __GNUC_PREREQ (8, 2)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncate"
return strncpy(dest, src, n);
#if __GNUC_PREREQ (8, 2)
#pragma GCC diagnostic pop

(if we really think this warning is worthwhile enough that we don't
just want to globally disable it, of course)

- Ted

P.S. It's really, really too bad there isn't a simpler way to shut up
gcc. You need the #ifdef __GNUC_PREREQ nonsense because otherwise
older versions of gcc that don't understand the particular warning
you're trying to suppress will complain loudly. (Ask me how I

 \ /
  Last update: 2018-08-20 02:03    [W:0.081 / U:1.632 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site