From: Bart Van Assche <bart.vanassche@wdc.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
Bart Van Assche <bart.vanassche@wdc.com>,
Martin Uecker <Martin.Uecker@med.uni-goettingen.de>,
Kees Cook <keescook@chromium.org>, Ingo Molnar <mingo@kernel.org>,
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
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 [thread overview]
Message-ID: <20180705161709.17028-1-bart.vanassche@wdc.com> (raw)
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 <bart.vanassche@wdc.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Martin Uecker <Martin.Uecker@med.uni-goettingen.de>
Cc: Kees Cook <keescook@chromium.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: <stable@vger.kernel.org>
---
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 <Martin.Uecker@med.uni-goettingen.de>
+ * Glory to Martin Uecker <Martin.Uecker@med.uni-goettingen.de>. 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
next reply other threads:[~2018-07-05 16:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-05 16:17 Bart Van Assche [this message]
2018-07-15 1:49 ` [PATCH] kernel.h: Avoid that sparse complains about using sizeof(void) Kees Cook
2018-07-15 1:57 ` Linus Torvalds
2018-07-15 1:59 ` Linus Torvalds
2018-07-15 3:28 ` Bart Van Assche
2018-07-15 4:07 ` Bart Van Assche
2018-07-16 15:21 ` konstantin
2018-07-15 20:24 ` Luc Van Oostenryck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180705161709.17028-1-bart.vanassche@wdc.com \
--to=bart.vanassche@wdc.com \
--cc=Martin.Uecker@med.uni-goettingen.de \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=mingo@kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox