From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752519AbdBJHxJ (ORCPT ); Fri, 10 Feb 2017 02:53:09 -0500 Received: from terminus.zytor.com ([65.50.211.136]:51550 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752110AbdBJHxH (ORCPT ); Fri, 10 Feb 2017 02:53:07 -0500 Date: Thu, 9 Feb 2017 23:52:38 -0800 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: hpa@zytor.com, tglx@linutronix.de, adrian.hunter@intel.com, acme@redhat.com, namhyung@kernel.org, wcohen@redhat.com, mingo@kernel.org, jolsa@kernel.org, wangnan0@huawei.com, linux-kernel@vger.kernel.org, dsahern@gmail.com Reply-To: wangnan0@huawei.com, jolsa@kernel.org, mingo@kernel.org, wcohen@redhat.com, dsahern@gmail.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com, namhyung@kernel.org, adrian.hunter@intel.com, acme@redhat.com To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] tools include: Add a __fallthrough statement Git-Commit-ID: b5bf1733d6a391c4e90ea8f8468d83023be74a2a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: b5bf1733d6a391c4e90ea8f8468d83023be74a2a Gitweb: http://git.kernel.org/tip/b5bf1733d6a391c4e90ea8f8468d83023be74a2a Author: Arnaldo Carvalho de Melo AuthorDate: Wed, 8 Feb 2017 17:01:46 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 8 Feb 2017 17:30:58 -0300 tools include: Add a __fallthrough statement For cases where implicit fall through case labels are intended, to let us inform that to gcc >= 7: CC /tmp/build/perf/util/string.o util/string.c: In function 'perf_atoll': util/string.c:22:7: error: this statement may fall through [-Werror=implicit-fallthrough=] if (*p) ^ util/string.c:24:3: note: here case '\0': ^~~~ So we introduce: #define __fallthrough __attribute__ ((fallthrough)) And use it in such cases. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Cc: William Cohen Link: http://lkml.kernel.org/n/tip-qnpig0xfop4hwv6k4mv1wts5@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/linux/compiler.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h index e33fc1d..d94179f 100644 --- a/tools/include/linux/compiler.h +++ b/tools/include/linux/compiler.h @@ -126,4 +126,13 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s #define WRITE_ONCE(x, val) \ ({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; __write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) + +#ifndef __fallthrough +# if defined(__GNUC__) && __GNUC__ >= 7 +# define __fallthrough __attribute__ ((fallthrough)) +# else +# define __fallthrough +# endif +#endif + #endif /* _TOOLS_LINUX_COMPILER_H */