From patchwork Fri Feb 10 17:08:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 9567499 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 75225601C3 for ; Fri, 10 Feb 2017 20:53:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64442285CF for ; Fri, 10 Feb 2017 20:53:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 573F1285D3; Fri, 10 Feb 2017 20:53:16 +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=-6.9 required=2.0 tests=BAYES_00,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 B6383285CF for ; Fri, 10 Feb 2017 20:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752168AbdBJUxP (ORCPT ); Fri, 10 Feb 2017 15:53:15 -0500 Received: from smtprelay0189.hostedemail.com ([216.40.44.189]:33901 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751238AbdBJUxO (ORCPT ); Fri, 10 Feb 2017 15:53:14 -0500 Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave04.hostedemail.com (Postfix) with ESMTP id E727FB1C40; Fri, 10 Feb 2017 17:10:24 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 6B856C1F81; Fri, 10 Feb 2017 17:08:41 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: fork79_4b64ed3505a47 X-Filterd-Recvd-Size: 2278 Received: from joe-laptop.perches.com (unknown [47.151.132.55]) (Authenticated sender: joe@perches.com) by omf09.hostedemail.com (Postfix) with ESMTPA; Fri, 10 Feb 2017 17:08:37 +0000 (UTC) From: Joe Perches To: Arnaldo Carvalho de Melo , Christopher Li Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-sparse@vger.kernel.org Subject: [PATCH] compiler/compiler-gcc: Add __fallthrough Date: Fri, 10 Feb 2017 09:08:35 -0800 Message-Id: <791a2621851fc989bc04dfe975ec29de15cbb557.1486746344.git.joe@perches.com> X-Mailer: git-send-email 2.10.0.rc2.1.g053435c In-Reply-To: <20170210144238.GC15066@kernel.org> References: <20170210144238.GC15066@kernel.org> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP gcc v7.0 can warn on missing break statements from case labels using a special __attribute__((fallthrough))__ marker. Add a __fallthrough convenience macro for gcc versions >= 7 and make the generic use of __fallthrough a no-op. Signed-off-by: Joe Perches --- include/linux/compiler-gcc.h | 7 +++++++ include/linux/compiler.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index d5e1fedbad24..6af8d6448f10 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -304,6 +304,13 @@ #define __no_sanitize_address __attribute__((no_sanitize_address)) #endif +#if GCC_VERSION >= 70000 +/* + * Tell the compiler not to warn when a switch/case fallthrough marker exists + */ +#define __fallthrough __attribute__ ((fallthrough)) +#endif + #endif /* gcc version >= 40000 specific checks */ #if !defined(__noclone) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 6e8e160b1e4b..16b6efc877f4 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -477,6 +477,12 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s #define __assume_aligned(a, ...) #endif +/* + * switch/case fallthrough checking + */ +#ifndef __fallthrough +#define __fallthrough +#endif /* Are two types/vars the same type (ignoring qualifiers)? */ #ifndef __same_type