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=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT 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 B60B0C43441 for ; Fri, 9 Nov 2018 09:35:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 878C620827 for ; Fri, 9 Nov 2018 09:35:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 878C620827 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sipsolutions.net 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 S1727999AbeKITPY (ORCPT ); Fri, 9 Nov 2018 14:15:24 -0500 Received: from s3.sipsolutions.net ([144.76.43.62]:55166 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727638AbeKITPX (ORCPT ); Fri, 9 Nov 2018 14:15:23 -0500 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.91) (envelope-from ) id 1gL3CU-0000te-Cz; Fri, 09 Nov 2018 10:35:38 +0100 From: Johannes Berg To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Johannes Berg Subject: [PATCH v2 2/3] kernel.h: hide __is_constexpr() from sparse Date: Fri, 9 Nov 2018 10:35:33 +0100 Message-Id: <20181109093534.15121-2-johannes@sipsolutions.net> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181109093534.15121-1-johannes@sipsolutions.net> References: <20181109093534.15121-1-johannes@sipsolutions.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg __is_constexpr() is a work of art, understandable only to the most respected wizards of C. Even sparse doesn't seem to belong to that group and warns that there's an "expression using sizeof(void)". Just hide the definition from sparse and pretend it's always true. Signed-off-by: Johannes Berg --- include/linux/kernel.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index d6aac75b51ba..d4d2233f95c9 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -844,6 +844,7 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } #define __typecheck(x, y) \ (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) +#ifndef __CHECKER__ /* * This returns a constant expression while determining if an argument is * a constant expression, most importantly without evaluating the argument. @@ -851,6 +852,13 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } */ #define __is_constexpr(x) \ (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) +#else +/* + * We don't really care about the check when running sparse and the + * above expression causes a warning due to sizeof(void). + */ +#define __is_constexpr(x) 1 +#endif #define __no_side_effects(x, y) \ (__is_constexpr(x) && __is_constexpr(y)) -- 2.17.2