From patchwork Fri Nov 16 07:54:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10685579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2250C109C for ; Fri, 16 Nov 2018 07:54:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14FF52D41D for ; Fri, 16 Nov 2018 07:54:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0958C2D427; Fri, 16 Nov 2018 07:54:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D80E52D41D for ; Fri, 16 Nov 2018 07:54:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727632AbeKPSFv (ORCPT ); Fri, 16 Nov 2018 13:05:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:46138 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727380AbeKPSFu (ORCPT ); Fri, 16 Nov 2018 13:05:50 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1B050ABDC; Fri, 16 Nov 2018 07:54:35 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: Su Yanjun Subject: [PATCH 2/9] btrfs-progs: fix gcc8 default build warning caused by '-Wformat-truncation' Date: Fri, 16 Nov 2018 15:54:19 +0800 Message-Id: <20181116075426.4142-3-wqu@suse.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116075426.4142-1-wqu@suse.com> References: <20181116075426.4142-1-wqu@suse.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Su Yanjun 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 [Use cc-disable-warning to fix the not working CFLAGS setting in configure.ac] Signed-off-by: Qu Wenruo --- 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