Re: [PATCH 1/2] testing/selftests: Add tests for the is_signed_type() macro

From: Bart Van Assche
Date: Tue Sep 06 2022 - 18:42:48 EST


On 8/30/22 02:41, Rasmus Villemoes wrote:
On 26/08/2022 18.21, Bart Van Assche wrote:
Although not documented, is_signed_type() must support the 'bool' and
pointer types next to scalar and enumeration types. Add a selftest that
verifies that this macro handles all supported types correctly.


+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);

Nice. You could consider adding

#ifdef __UNSIGNED_CHAR__
KUNIT_EXPECT_EQ(test, is_signed_type(char), false);
#else
KUNIT_EXPECT_EQ(test, is_signed_type(char), true);
#endif

The kernel depends on the compiler providing __UNSIGNED_CHAR__ in two
places (one in ext4, one in printf test suite).

(reduced Cc-list)

Hi Rasmus,

Since I would like to implement the above suggestion I tried to look up other uses of the __UNSIGNED_CHAR__ macro. However, I couldn't find any. Did I perhaps do something wrong?
$ git grep -w __UNSIGNED_CHAR__ origin/master | wc
0 0 0

Thanks,

Bart.