All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: David Laight <david.laight.linux@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Chris Li <sparse@chrisli.org>
Subject: Re: [PATCH v2] tracing: Make is_signed_type() compatible with sparse
Date: Tue, 1 Sep 2026 11:05:18 -0700	[thread overview]
Message-ID: <dca931ff-5995-444c-9f89-6d6cca4e71f3@acm.org> (raw)
In-Reply-To: <20260901092043.7feaf5d7@pumpkin>

On 9/1/26 1:20 AM, David Laight wrote:
> I suspect you need to change the TRACE_EVENT() calls to remove the
> __bitwise marker.

How to remove the __bitwise marker? Removing the __bitwise marker is not
supported by sparse, isn't it?

How about the changes shown below (should be split into two patches)?

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index cb2f6050bdf7..54c99a25caa5 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -326,7 +326,14 @@ static inline void *offset_to_ptr(const int *off)
   * Whether 'type' is a signed type or an unsigned type. Supports 
scalar types,
   * bool and also pointer types.
   */
-#define is_signed_type(type) (((type)(-1)) < (__force type)1)
+#define is_signed_type(type) _Generic(((TYPEOF_UNQUAL(type))0),	\
+	signed char: true,			\
+	signed short: true,			\
+	signed int: true,			\
+	signed long: true,			\
+	signed long long: true,			\
+	char: ((char)-1 < (char)1),		\
+	default: false)
  #define is_unsigned_type(type) (!is_signed_type(type))

  /*
diff --git a/lib/tests/is_signed_type_kunit.c 
b/lib/tests/is_signed_type_kunit.c
index 88adbe813f3a..b72da7f6084f 100644
--- a/lib/tests/is_signed_type_kunit.c
+++ b/lib/tests/is_signed_type_kunit.c
@@ -22,6 +22,8 @@ static void is_signed_type_test(struct kunit *test)
  	KUNIT_EXPECT_EQ(test, is_signed_type(signed char), true);
  	KUNIT_EXPECT_EQ(test, is_signed_type(unsigned char), false);
  	KUNIT_EXPECT_EQ(test, is_signed_type(char), false);
+	KUNIT_EXPECT_EQ(test, is_signed_type(short), true);
+	KUNIT_EXPECT_EQ(test, is_signed_type(unsigned short), false);
  	KUNIT_EXPECT_EQ(test, is_signed_type(int), true);
  	KUNIT_EXPECT_EQ(test, is_signed_type(unsigned int), false);
  	KUNIT_EXPECT_EQ(test, is_signed_type(long), true);
@@ -32,6 +34,13 @@ static void is_signed_type_test(struct kunit *test)
  	KUNIT_EXPECT_EQ(test, is_signed_type(enum signed_enum), true);
  	KUNIT_EXPECT_EQ(test, is_signed_type(void *), false);
  	KUNIT_EXPECT_EQ(test, is_signed_type(const char *), false);
+	KUNIT_EXPECT_EQ(test, is_signed_type(int (*)(void)), false);
+
+	KUNIT_EXPECT_EQ(test, is_signed_type(const int), true);
+	KUNIT_EXPECT_EQ(test, is_signed_type(const unsigned int), false);
+
+	KUNIT_EXPECT_EQ(test, is_signed_type(volatile int), true);
+	KUNIT_EXPECT_EQ(test, is_signed_type(volatile unsigned int), false);
  }

  static struct kunit_case is_signed_type_test_cases[] = {

Thanks,

Bart.

  reply	other threads:[~2026-09-01 18:05 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07 17:00 [PATCH v2] tracing: Make is_signed_type() compatible with sparse Bart Van Assche
2026-08-31  0:20 ` Bart Van Assche
2026-08-31 14:27   ` Steven Rostedt
2026-08-31 20:44 ` David Laight
2026-08-31 21:19   ` Bart Van Assche
2026-09-01  8:20     ` David Laight
2026-09-01 18:05       ` Bart Van Assche [this message]
2026-09-01 18:45         ` Linus Torvalds
2026-09-01 19:22           ` Bart Van Assche
2026-09-01 19:35             ` Linus Torvalds
2026-09-01 19:38               ` Linus Torvalds
2026-09-01 20:06               ` Bart Van Assche
2026-09-01 20:24                 ` Linus Torvalds
2026-09-01 22:46                   ` Bart Van Assche
2026-09-05  7:48                     ` Uwe Kleine-König
2026-09-01 21:29         ` David Laight
2026-09-01 21:43           ` Bart Van Assche
2026-09-01 21:56             ` Linus Torvalds
2026-09-01 23:25               ` Steven Rostedt
2026-09-02  8:24                 ` David Laight
2026-09-02 13:36                   ` Steven Rostedt
2026-09-02 15:16                     ` David Laight
2026-09-02 16:31                     ` Bart Van Assche
2026-09-02 16:39                       ` Steven Rostedt
2026-09-02 16:44                         ` Bart Van Assche
2026-09-02 16:54                           ` Steven Rostedt
2026-09-02 17:04                             ` Linus Torvalds
2026-09-02 17:24                               ` Steven Rostedt
2026-09-02 18:06                           ` David Laight
2026-09-02 18:21                             ` Steven Rostedt
2026-09-02 20:50                               ` David Laight
2026-09-02 22:40                                 ` Bart Van Assche
2026-09-02 22:43                                 ` Linus Torvalds
2026-09-02 16:52                         ` Linus Torvalds
2026-09-03 21:50                 ` Vincent Mailhol
2026-09-04  0:26                   ` Steven Rostedt

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=dca931ff-5995-444c-9f89-6d6cca4e71f3@acm.org \
    --to=bvanassche@acm.org \
    --cc=david.laight.linux@gmail.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=sparse@chrisli.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.