From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH 01/10] mk: adjust gcc flags for new gcc 7 warnings Date: Thu, 4 May 2017 09:38:08 -0700 Message-ID: <20170504093808.12ea9c07@xeon-e3> References: <20170504153822.19461-1-bruce.richardson@intel.com> <20170504153822.19461-2-bruce.richardson@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Bruce Richardson Return-path: Received: from mail-pg0-f45.google.com (mail-pg0-f45.google.com [74.125.83.45]) by dpdk.org (Postfix) with ESMTP id 3211C7CF8 for ; Thu, 4 May 2017 18:38:15 +0200 (CEST) Received: by mail-pg0-f45.google.com with SMTP id q4so3569454pga.3 for ; Thu, 04 May 2017 09:38:15 -0700 (PDT) In-Reply-To: <20170504153822.19461-2-bruce.richardson@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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