Return-Path: Received: from esa2.hgst.iphmx.com ([68.232.143.124]:7113 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753806AbeGEQRK (ORCPT ); Thu, 5 Jul 2018 12:17:10 -0400 From: Bart Van Assche To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Bart Van Assche , Martin Uecker , Kees Cook , Ingo Molnar , Miguel Ojeda , stable@vger.kernel.org Subject: [PATCH] kernel.h: Avoid that sparse complains about using sizeof(void) Date: Thu, 5 Jul 2018 09:17:09 -0700 Message-Id: <20180705161709.17028-1-bart.vanassche@wdc.com> Sender: stable-owner@vger.kernel.org List-ID: The macro __is_constexpr() causes sparse to report the following: warning: expression using sizeof(void) Avoid this by using __builtin_constant_p() instead. Fixes: 3c8ba0d61d04 ("kernel.h: Retain constant expression output for max()/min()") Signed-off-by: Bart Van Assche Cc: Linus Torvalds Cc: Martin Uecker Cc: Kees Cook Cc: Ingo Molnar Cc: Miguel Ojeda Cc: --- include/linux/kernel.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index d23123238534..a9f0d0d48971 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -811,13 +811,19 @@ 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. - * Glory to Martin Uecker + * Glory to Martin Uecker . However, this + * macro causes sparse to report the warning "expression using sizeof(void)". + * Hence use __builtin_constant_p() instead when using sparse. */ #define __is_constexpr(x) \ (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) +#else +#define __is_constexpr(x) __builtin_constant_p((x)) +#endif #define __no_side_effects(x, y) \ (__is_constexpr(x) && __is_constexpr(y)) -- 2.18.0