From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id F15092C18 for ; Fri, 5 May 2017 11:42:17 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP; 05 May 2017 02:42:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,291,1491289200"; d="scan'208";a="95977735" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.221.42]) by orsmga005.jf.intel.com with SMTP; 05 May 2017 02:42:15 -0700 Received: by (sSMTP sendmail emulation); Fri, 05 May 2017 10:42:14 +0100 Date: Fri, 5 May 2017 10:42:13 +0100 From: Bruce Richardson To: Stephen Hemminger Cc: dev@dpdk.org Message-ID: <20170505094213.GA42716@bricha3-MOBL3.ger.corp.intel.com> References: <20170504153822.19461-1-bruce.richardson@intel.com> <20170504153822.19461-2-bruce.richardson@intel.com> <20170504093808.12ea9c07@xeon-e3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170504093808.12ea9c07@xeon-e3> Organization: Intel Research and =?iso-8859-1?Q?De=ACvel?= =?iso-8859-1?Q?opment?= Ireland Ltd. User-Agent: Mutt/1.8.0 (2017-02-23) Subject: Re: [dpdk-dev] [PATCH 01/10] mk: adjust gcc flags for new gcc 7 warnings X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 May 2017 09:42:18 -0000 On Thu, May 04, 2017 at 09:38:08AM -0700, Stephen Hemminger wrote: > On Thu, 4 May 2017 16:38:13 +0100 > Bruce Richardson wrote: > > > There are two new warnings in GCC 7 that cause problems in the DPDK > > compile. > > > > 1. GCC now warns if you have a switch fall-through without a suitable > > comment indicating that it was intentional. The compiler supports a number > > of levels of warning which are triggered depending on the type of message > > used, with level 3 being the default. To accept a wider range of possible > > fall-through messages, we adjust this down to level 2. > > > > 2. GCC also warns about an snprintf where there may be truncation and the > > return value is not checked. Given that we often use snprintf in DPDK in > > place of strncpy, and in many cases where truncation is not a problem, we > > can just disable this particular warning. > > > > Signed-off-by: Bruce Richardson > > --- > > mk/toolchain/gcc/rte.vars.mk | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk > > index 5caa600..3834e00 100644 > > --- a/mk/toolchain/gcc/rte.vars.mk > > +++ b/mk/toolchain/gcc/rte.vars.mk > > @@ -99,5 +99,12 @@ ifeq ($(shell test $(GCC_VERSION) -lt 47 && echo 1), 1) > > WERROR_FLAGS += -Wno-uninitialized > > endif > > > > +ifeq ($(shell test $(GCC_VERSION) -gt 70 && echo 1), 1) > > +# Tell GCC only to error for switch fallthroughs without a suitable comment > > +WERROR_FLAGS += -Wimplicit-fallthrough=2 > > +# Ignore errors for snprintf truncation > > +WERROR_FLAGS += -Wno-format-truncation > > +endif > > + > > export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF > > export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS > > Please fix the code not neuter warnings As much as is possible I agree. However, for these two warnings: 1. the implicit fallthrough warning is not disabled, it's just adjusted to allow a wider range of comments for fall-through to be accepted. The rest of the set implements fixes for a number of these warnings in the code. 2. for the format truncation warning, ideally, yes we should fix the code, except that I don't believe this is feasible in the short term, and I also don't believe it is desirable. We extensively use snprintf because it has sane/safe truncation, and in many cases we don't care if it is being truncated. Therefore disabling the warning seems the best approach to me. Furthermore, if we want 17.05 to compile with GCC 7, this is the best option within that timeframe. Regards, /Bruce