From patchwork Sat Sep 8 21:24:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10593211 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 30340109C for ; Sat, 8 Sep 2018 21:26:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ECBA29F31 for ; Sat, 8 Sep 2018 21:26:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1065D29F48; Sat, 8 Sep 2018 21:26:21 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 733D629F31 for ; Sat, 8 Sep 2018 21:26:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727616AbeIICNW (ORCPT ); Sat, 8 Sep 2018 22:13:22 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38756 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727694AbeIICM0 (ORCPT ); Sat, 8 Sep 2018 22:12:26 -0400 Received: by mail-wm0-f66.google.com with SMTP id t25-v6so17659934wmi.3; Sat, 08 Sep 2018 14:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5ELqCquol9uLIAR1HjMyJP27IPe/3rVJEhfvVxeS1Hw=; b=PdNsgtfZbphrH97gnteJQxvLOwe/d9Q+XERb2klYepe2du+0JFriuRKlFW5zlVrSlp wEHw71QQNZQCn1TUNywM77KsmigEt2PjX9ygYwegEIls8fBF+YnToXIFxuXFib3I9zM9 vW8S1GEGkrqkKFNq3wr26d743ZwNGHFMDVzeKklGZd3Jd8jjw9ARybQ7XA+Tk4vnHC4e 9BBg+em0tK8Bp56JmEuuWdBw7bNFoJM8sMBOgrWlbHQj20ECqcK4HGJzmw+zuFWKXuuH 0nK7hpBKZCegDXj7QWurqL3N3rps6wyhLrlE19McafIxKH1UhZ+n9fu4Tw3ot7X4hSQ3 rFUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5ELqCquol9uLIAR1HjMyJP27IPe/3rVJEhfvVxeS1Hw=; b=qM1/DQVy4uN//tn52Wowb3SYWniVN/f8ZVFgRvDh11CLsX3yxyM8gF2mVKl4Dvfw33 uYCXD3czJYIdkYrTBpZnm+XNhaeUyNPm1XY8XBNIjPE6XJl0am6UMGvfrNy9Nf5JfvsZ Bv4/AKc3WJUDgHsb0x+wGfC1bQzHi42Bkws0Y6T4GNxBuWkj/K0qCjuFrLlOvc7508HT iCuorK+4utQJKRSD9NwvgYX8S3e74IoP1tokD+ay5GJgfEFsSFFxjvFE/n6xe6/z1q9f 8FYhs/CUqzeUHKgOCImhthoCb4AFqk4lNyt3/wn7x/1QgxcPKH2H3rAeUSvee3ii8sOZ J5XQ== X-Gm-Message-State: APzg51Bkn/LYrzgZ3UuicibkXjaDaXZO2wEZbimpnlcE6PsWzLU7IM1D a7RTrWJOu2WhMqXaceiTYMs= X-Google-Smtp-Source: ANB0VdbHFFPDnydgS7Un3kwKCFgxdeK7cKjFUdxBeznpMjQA27/VceL0cvMLw96OnDDHhRk+WB6mBg== X-Received: by 2002:a1c:f913:: with SMTP id x19-v6mr8759501wmh.63.1536441916672; Sat, 08 Sep 2018 14:25:16 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id u40-v6sm17340786wrc.43.2018.09.08.14.25.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Sep 2018 14:25:16 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Rasmus Villemoes , Luc Van Oostenryck , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , linux-sparse@vger.kernel.org Subject: [PATCH v4 04/13] Compiler Attributes: homogenize __must_be_array Date: Sat, 8 Sep 2018 23:24:50 +0200 Message-Id: <20180908212459.19736-5-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180908212459.19736-1-miguel.ojeda.sandonis@gmail.com> References: <20180908212459.19736-1-miguel.ojeda.sandonis@gmail.com> 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 Different definitions of __must_be_array: * gcc: disabled for __CHECKER__ * clang: same definition as gcc's, but without __CHECKER__ * intel: the comment claims __builtin_types_compatible_p() is unsupported; but icc seems to support it since 13.0.1 (released in 2012). See https://godbolt.org/z/S0l6QQ Therefore, we can remove all of them and have a single definition in compiler.h Cc: Rasmus Villemoes Cc: Luc Van Oostenryck Cc: Eli Friedman Cc: Christopher Li Cc: Kees Cook Cc: Ingo Molnar Cc: Geert Uytterhoeven Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Cc: Masahiro Yamada Cc: Joe Perches Cc: Dominique Martinet Cc: Linus Torvalds Cc: linux-sparse@vger.kernel.org Reviewed-by: Nick Desaulniers Signed-off-by: Miguel Ojeda --- include/linux/compiler-clang.h | 1 - include/linux/compiler-gcc.h | 7 ------- include/linux/compiler-intel.h | 3 --- include/linux/compiler.h | 7 +++++++ 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index d11cad61ba5c..fa9532f8d885 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -41,6 +41,5 @@ * compilers, like ICC. */ #define barrier() __asm__ __volatile__("" : : : "memory") -#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) #define __assume_aligned(a, ...) \ __attribute__((__assume_aligned__(a, ## __VA_ARGS__))) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 371b6fa2d074..76f4907ef707 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -68,13 +68,6 @@ */ #define uninitialized_var(x) x = x -#ifdef __CHECKER__ -#define __must_be_array(a) 0 -#else -/* &a[0] degrades to a pointer: a different type from an array */ -#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) -#endif - #ifdef RETPOLINE #define __noretpoline __attribute__((__indirect_branch__("keep"))) #endif diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h index fef8bb3e53ef..6004b4588bd4 100644 --- a/include/linux/compiler-intel.h +++ b/include/linux/compiler-intel.h @@ -29,9 +29,6 @@ */ #define OPTIMIZER_HIDE_VAR(var) barrier() -/* Intel ECC compiler doesn't support __builtin_types_compatible_p() */ -#define __must_be_array(a) 0 - #endif /* icc has this, but it's called _bswap16 */ diff --git a/include/linux/compiler.h b/include/linux/compiler.h index ec4a28bad2c6..165b1d5683ed 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -357,4 +357,11 @@ static inline void *offset_to_ptr(const int *off) compiletime_assert(__native_word(t), \ "Need native word sized stores/loads for atomicity.") +#ifdef __CHECKER__ +#define __must_be_array(a) 0 +#else +/* &a[0] degrades to a pointer: a different type from an array */ +#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) +#endif + #endif /* __LINUX_COMPILER_H */