Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1033130imm; Sat, 8 Sep 2018 14:28:17 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb+NuJjSsUAiouZjomdJxOg2IUc3+ZFDrLSrAmzA1mWhWWyM63tGadATPCnd9ihCfLcav34 X-Received: by 2002:a17:902:28c7:: with SMTP id f65-v6mr14414698plb.240.1536442097219; Sat, 08 Sep 2018 14:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536442097; cv=none; d=google.com; s=arc-20160816; b=gv7rhdftziD9/fIolkJ1LjQysxijGuQP+qtAlrxek8AAKOW8BwnAAmpcnmTcp11AmP //RivnQLG7A+XKNK3NKHa1Sf/CSJu1APgYYjOeJ4KzFnhsE1qCvMwHUFUPTUaMLeQdnB 4GG/oHh89nQBJOsnKOakgYTNmIhWp1fzU8/loxCPV3pCnfO//Mf5CzAtX+i/wnJn2NM3 kx4+ZQA/EvyGLizBCQ+KgeaL6VVH+sMKDPMKDd+TUGhrMcs53k1roJWNn9LqopCviUwS 53FMRaYB2wztvvbleg8eD6Y3i221UGyzg+BvZloXjKuUYOMan/rDNqWI457Ym4E1DIzV 3rsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=5ELqCquol9uLIAR1HjMyJP27IPe/3rVJEhfvVxeS1Hw=; b=ZMtQ40g6SQb4JTFInohNMy13B0DMTehLFRq9KxtTH4tdchL8V1tB3IrAT5mYEGy8FN svOF/eKY1Vc6KLR97ckalTKC/qVpoH4lQ4IvNe185mKHOPtF4/JC0O9wDUs2+AhEEwIr vK7t8Ndkx/XM4UViakkXsaqEnY+MZueAIA5Og7U2aqzGf3zGKrajRkKABGcJ4z8BmGck 8+ss4ln+myEMZ3TiGQ9dAiwD9z2Q+xK9/4WU7P8DFX7zPgsVc+7WIqzU8/je1LYIC98X UwmJJ7Dm0k88p7NjZ/2zNbzzNUzv10SmjS3HKlbFHKrnuX58u/O7kKJd+wOlcsqfVpS+ 4TXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PdNsgtfZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7-v6si11493479pgp.411.2018.09.08.14.28.01; Sat, 08 Sep 2018 14:28:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PdNsgtfZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728146AbeIICNW (ORCPT + 99 others); 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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ -- 2.17.1