All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Y. Ts'o" <tytso@mit.edu>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Linux-Next Mailing List <linux-next@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: linux-next: build warnings from Linus' tree
Date: Sun, 19 Aug 2018 20:02:18 -0400	[thread overview]
Message-ID: <20180820000218.GE19200@thunk.org> (raw)
In-Reply-To: <20180820081323.23a47af3@canb.auug.org.au>

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"
#endif
	return strncpy(dest, src, n);
#if __GNUC_PREREQ (8, 2)
#pragma GCC diagnostic pop
#endif
}

(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
know....)

  parent reply	other threads:[~2018-08-20  0:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-19 22:13 linux-next: build warnings from Linus' tree Stephen Rothwell
2018-08-19 22:16 ` Stephen Rothwell
2018-08-19 22:40   ` Stephen Rothwell
2018-08-19 23:21 ` Linus Torvalds
2018-08-20  1:33   ` Adam Borowski
2018-08-20  2:53     ` Theodore Y. Ts'o
2018-08-20  0:02 ` Theodore Y. Ts'o [this message]
2018-08-20 17:47   ` Miguel Ojeda
  -- strict thread matches above, loose matches on Subject: below --
2019-08-29 21:59 Stephen Rothwell
2018-06-11 22:14 Stephen Rothwell
2018-11-14  4:54 ` Joel Stanley
2018-11-14  4:54   ` Joel Stanley
2018-11-14 10:20   ` Michael Ellerman
2018-11-14 10:20     ` Michael Ellerman
2018-11-14 10:20     ` Michael Ellerman
2018-11-18 11:22     ` Alan Modra
2018-11-18 11:22       ` Alan Modra
2018-12-03 23:24       ` Joel Stanley
2018-12-03 23:24         ` Joel Stanley
2010-10-28  0:27 Stephen Rothwell
2010-10-28  3:04 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180820000218.GE19200@thunk.org \
    --to=tytso@mit.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.