mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] lib: Improve the is_signed_type() kunit test
@ 2022-09-07 18:03 Bart Van Assche
  2022-09-07 22:57 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Van Assche @ 2022-09-07 18:03 UTC (permalink / raw)
  To: Kees Cook; +Cc: linux-kernel, Bart Van Assche, Isabella Basso, Rasmus Villemoes

Since the definition of is_signed_type() has been moved from
<linux/overflow.h> to <linux/compiler.h>, include the latter header file
instead of the former. Additionally, add a test for the type 'char'.

Cc: Isabella Basso <isabbasso@riseup.net>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 lib/is_signed_type_kunit.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/is_signed_type_kunit.c b/lib/is_signed_type_kunit.c
index f2eedb1f0935..207207522925 100644
--- a/lib/is_signed_type_kunit.c
+++ b/lib/is_signed_type_kunit.c
@@ -5,7 +5,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <kunit/test.h>
-#include <linux/overflow.h>
+#include <linux/compiler.h>
 
 enum unsigned_enum {
 	constant_a = 3,
@@ -21,6 +21,11 @@ static void is_signed_type_test(struct kunit *test)
 	KUNIT_EXPECT_EQ(test, is_signed_type(bool), false);
 	KUNIT_EXPECT_EQ(test, is_signed_type(signed char), true);
 	KUNIT_EXPECT_EQ(test, is_signed_type(unsigned char), false);
+#ifdef __CHAR_UNSIGNED__
+	KUNIT_EXPECT_EQ(test, is_signed_type(char), false);
+#else
+	KUNIT_EXPECT_EQ(test, is_signed_type(char), true);
+#endif
 	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);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-07 22:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07 18:03 [PATCH] lib: Improve the is_signed_type() kunit test Bart Van Assche
2022-09-07 22:57 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®