From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C291C43334 for ; Mon, 3 Sep 2018 20:34:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C4A972086B for ; Mon, 3 Sep 2018 20:34:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PZ8lRtcq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4A972086B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729241AbeIDA4b (ORCPT ); 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-Google-Smtp-Source: ANB0VdaUn36qgIxj0m4yhJJofzQE3fQN9+UIPEVgqfvXEdDIq3n8tlld4j5U9SglnXPaQMEes7+vJQ== 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