Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1938579imm; Mon, 3 Sep 2018 13:36:35 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdaym8HkasHZIwtCEBHRdcXnHiUKLPcZ9y8VLa10OXGt04Yy19t0V3UDfG7Sii2qYAyBNRK5 X-Received: by 2002:a63:5706:: with SMTP id l6-v6mr28669997pgb.118.1536006995477; Mon, 03 Sep 2018 13:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536006995; cv=none; d=google.com; s=arc-20160816; b=nG0sZiZzgjBGAdnkkEtEztWLsinTMwnMEzbgb3hGVyvVSCrqWHyXjYIR10dWEZW7R8 gwugDWBN2GFXvCYB/uPv0Q/i8N+wB3JJHJL6ZjHH/cL+SNbR+RdL5utTT0cV4kTA8xfS 1vWUAyqnEDTsnmK47FzHh+puOBOwOFAJUY4GalqGP8HH69eyeWMNfTGXV2A0Dw5ju1Sj nlFVPfEg4nzFFx3VxmBEvgZmUu1OwTcgJsUhaLbawJTceq934K/qyGnPEIowwGYcjTzp D8vpHlUw8rXcFvJuOiTz9a5oV0PIFCP0Gthn+TsOLQpC3tsVtwmUeqmTiB5l9HnfTa70 IIAA== 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:arc-authentication-results; bh=5ELqCquol9uLIAR1HjMyJP27IPe/3rVJEhfvVxeS1Hw=; b=a9JjGn1pc/FatGpPq1XoC6YUccd/BLpe/YlC71sbSVg+vrPsZZFLay3JHxbw27D6b1 gXHRMq8qPZ6IYxeS5qZUgwDlb/wdqyMtHwPkjMRfE2xHApDLfn0Mi3rFH7S707Bz4IKV j0j892Gg1Cus8edDt7rHqkoylT0dcddzz2r92E0cKU5sLfezgkk8YMmu5r7E6pyBaBN6 n3907Td88fXiGHVLwSuhHR+/eUz+pi+xRqBwHKC3t21f8BErJc8OyJs2HAIMYQO9ysYl Y3PItTbOVu4xgik4auJUBhS/P6f/xYnehhpcnwkKJ7d5CBhbQTjMW7mtp5uSl4vqD7Ac djaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PZ8lRtcq; 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 1-v6si20273731pfx.293.2018.09.03.13.36.20; Mon, 03 Sep 2018 13:36:35 -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=PZ8lRtcq; 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 S1729237AbeIDA4b (ORCPT + 99 others); Mon, 3 Sep 2018 20:56:31 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:54350 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728876AbeIDAzp (ORCPT ); Mon, 3 Sep 2018 20:55:45 -0400 Received: by mail-wm0-f66.google.com with SMTP id c14-v6so2242981wmb.4; Mon, 03 Sep 2018 13:33:53 -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=PZ8lRtcqCAREJWRk7OxHdLuKGL+jzw1ZlDYOrrlBzTe/zJ3OId2+DCFk/hheMvFJze MJoyCY4mGKR24QbUfRkTJDA3Vj2tmCbQiiW0+lczSfEmp5CmkRfqPWFa21sMQbj/qppz KVOwRfQQT3B7zSjqUzxoPNmRPMbguD9V9LmkocXOIs9mu3mAC+WYbgCu6wb5mOogArmn 5u2b85UYjehJ/XYANLn0vCcTrwUBOO8FomriMxyguHOr5UJUwqIIIoqZotbtroHexW1X EPds6Ced997TL+QYG3DspwJkOXHIRFKdIO6CTxF+YmbwFs8ZjyzIhX1yPsB3Fl99PsvH UbbA== 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=IRqgWvZnhxluAT5x2qZ1frIYK8BVojHIw2PDtefqJM/eedw/zHymd39qu726QGkTOu iI1tuMKIQsIf4vgdcclGD7wME404E61X1kNrpGxCzpoEI4ChDCSJuoTl7kSDn6d7k2Sp txXpwUo1g+/W8/L1/m9M6rW6K8eiM9h5CztRHexMMEs/8iQq4Ov3QWx6pAolhGQYxFOO Y9dOHpGhR1zqiXu0QEE9wGwNx2laZGEfBG9SbsMzShiJRe7b/PhfJEiGxsUDCAZHfiAk WmFmCrDPSp5uRwc/5/NtRkKIJmdQmdzn8LJQnvSTQUzfF+AzB/pRabHW5E7Pp/4sD9du 7Dpw== X-Gm-Message-State: APzg51BB1y2Bb7xrh6D9OXRSCwlSVidsgpX1IUpCXdqGd268xf0b/ZV8 wB7hNz9g/z1DjZMz02F0Vy4= X-Received: by 2002:a1c:cf08:: with SMTP id f8-v6mr6412283wmg.27.1536006832580; Mon, 03 Sep 2018 13:33:52 -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 132-v6sm12354870wmd.13.2018.09.03.13.33.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:33:51 -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 04/12] Compiler Attributes: homogenize __must_be_array Date: Mon, 3 Sep 2018 22:33:08 +0200 Message-Id: <20180903203316.16183-5-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-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