All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Su Yanjun <suyj.fnst@cn.fujitsu.com>
Subject: [PATCH 2/9] btrfs-progs: fix gcc8 default build warning caused by '-Wformat-truncation'
Date: Fri, 16 Nov 2018 15:54:19 +0800	[thread overview]
Message-ID: <20181116075426.4142-3-wqu@suse.com> (raw)
In-Reply-To: <20181116075426.4142-1-wqu@suse.com>

From: Su Yanjun <suyj.fnst@cn.fujitsu.com>

When using gcc8 compiles utils.c, it complains as below:

utils.c:852:45: warning: '%s' directive output may be truncated writing
up to 4095 bytes into a region of size 4084 [-Wformat-truncation=]
   snprintf(path, sizeof(path), "/dev/mapper/%s", name);
                                             ^~   ~~~~
In file included from /usr/include/stdio.h:873,
                 from utils.c:20:
/usr/include/bits/stdio2.h:67:10: note: '__builtin___snprintf_chk'
output between 13 and 4108 bytes into a destination of size 4096
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This isn't a type of warning we care about, particularly when PATH_MAX
is much less than either.

Using the GCC option -Wno-format-truncation to disable this for default
build.

Signed-off-by: Su Yanjun <suyj.fnst@cn.fujitsu.com>
[Use cc-disable-warning to fix the not working CFLAGS setting in configure.ac]
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 Makefile           | 1 +
 Makefile.extrawarn | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Makefile b/Makefile
index f4ab14ea74c8..252299f8869f 100644
--- a/Makefile
+++ b/Makefile
@@ -49,6 +49,7 @@ CSCOPE_CMD := cscope -u -b -c -q
 include Makefile.extrawarn
 
 EXTRA_CFLAGS :=
+EXTRA_CFLAGS += $(call cc-disable-warning, format-truncation)
 EXTRA_LDFLAGS :=
 
 DEBUG_CFLAGS_DEFAULT = -O0 -U_FORTIFY_SOURCE -ggdb3
diff --git a/Makefile.extrawarn b/Makefile.extrawarn
index 5849036fd166..bbb2d5173846 100644
--- a/Makefile.extrawarn
+++ b/Makefile.extrawarn
@@ -53,6 +53,7 @@ warning-1 += -Wold-style-definition
 warning-1 += $(call cc-option, -Wmissing-include-dirs)
 warning-1 += $(call cc-option, -Wunused-but-set-variable)
 warning-1 += $(call cc-disable-warning, missing-field-initializers)
+warning-1 += $(call cc-disable-warning, format-truncation)
 
 warning-2 := -Waggregate-return
 warning-2 += -Wcast-align
-- 
2.19.1


  parent reply	other threads:[~2018-11-16  7:54 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16  7:54 [PATCH 0/9] btrfs-progs: Make W=1 clean (no "again") Qu Wenruo
2018-11-16  7:54 ` [PATCH 1/9] btrfs-progs: Makefile.extrawarn: Import cc-disable-warning Qu Wenruo
2018-12-04 11:04   ` David Sterba
2018-11-16  7:54 ` Qu Wenruo [this message]
2018-12-04 11:10   ` [PATCH 2/9] btrfs-progs: fix gcc8 default build warning caused by '-Wformat-truncation' David Sterba
2018-12-04 12:21     ` Qu Wenruo
2018-11-16  7:54 ` [PATCH 3/9] btrfs-progs: Makefile.extrawarn: Don't warn on sign compare Qu Wenruo
2018-11-16  8:00   ` [PATCH v1.1 " Qu Wenruo
2018-12-04 11:10     ` David Sterba
2018-11-16  7:54 ` [PATCH 4/9] btrfs-progs: Fix Wempty-body warning Qu Wenruo
2018-11-16  8:01   ` Nikolay Borisov
2018-11-16  7:54 ` [PATCH 5/9] btrfs-progs: Fix Wimplicit-fallthrough warning Qu Wenruo
2018-11-16  8:04   ` Nikolay Borisov
2018-11-16  8:10     ` Qu Wenruo
2018-11-16  7:54 ` [PATCH 6/9] btrfs-progs: Fix Wsuggest-attribute=format warning Qu Wenruo
2018-11-16  8:06   ` Nikolay Borisov
2018-11-16  7:54 ` [PATCH 7/9] btrfs-progs: Fix Wmaybe-uninitialized warning Qu Wenruo
2018-11-16  8:13   ` Nikolay Borisov
2018-11-16  8:16     ` Qu Wenruo
2018-11-16  8:22   ` [PATCH v1.1 " Qu Wenruo
2018-11-16  8:24     ` Nikolay Borisov
2018-12-04 12:17   ` [PATCH " David Sterba
2018-12-04 12:22     ` Adam Borowski
2018-12-04 12:42       ` Nikolay Borisov
2018-12-05  5:38     ` Qu Wenruo
2018-11-16  7:54 ` [PATCH 8/9] btrfs-progs: Fix Wtype-limits warning Qu Wenruo
2018-11-16  8:07   ` Nikolay Borisov
2018-11-16  7:54 ` [PATCH 9/9] btrfs-progs: Cleanup warning reported by -Wmissing-prototypes except free space tree Qu Wenruo
2018-11-16  8:04   ` [PATCH v1.1 9/9] btrfs-progs: Cleanup warning reported by -Wmissing-prototypes Qu Wenruo
2018-11-16  8:14     ` Nikolay Borisov
2018-12-04 12:22     ` David Sterba
2018-12-04 12:24       ` Qu Wenruo
2018-12-04 12:48         ` David Sterba

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=20181116075426.4142-3-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=suyj.fnst@cn.fujitsu.com \
    /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.