Skip to content

Commit dce1b33

Browse files
committed
selftests: harness: Rename is_signed_type() to avoid collision with overflow.h
Rename is_signed_type() to is_signed_var() to avoid colliding with a macro of the same name defined by tools' linux/overflow.h. This fixes warnings (and presumably potential test failures) in tests that utilize the selftests harness and happen to (indirectly) include overflow.h. In file included from tools/include/linux/bits.h:34, from tools/include/linux/bitops.h:14, from tools/include/linux/hashtable.h:13, from include/kvm_util.h:11, from x86/userspace_msr_exit_test.c:11: tools/include/linux/overflow.h:31:9: error: "is_signed_type" redefined [-Werror] 31 | #define is_signed_type(type) (((type)(-1)) < (type)1) | ^~~~~~~~~~~~~~ In file included from include/kvm_test_harness.h:11, from x86/userspace_msr_exit_test.c:9: ../kselftest_harness.h:754:9: note: this is the location of the previous definition 754 | #define is_signed_type(var) (!!(((__typeof__(var))(-1)) < (__typeof__(var))1)) | ^~~~~~~~~~~~~~ Use a separate definition, at least for now, as many selftests build without tools/include in their include path. Fixes: fc92099 ("tools headers: Synchronize linux/bits.h with the kernel sources") Cc: Vincent Mailhol <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 923fcb3 commit dce1b33

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/testing/selftests/kselftest_harness.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,15 +751,15 @@
751751
for (; _metadata->trigger; _metadata->trigger = \
752752
__bail(_assert, _metadata))
753753

754-
#define is_signed_type(var) (!!(((__typeof__(var))(-1)) < (__typeof__(var))1))
754+
#define is_signed_var(var) (!!(((__typeof__(var))(-1)) < (__typeof__(var))1))
755755

756756
#define __EXPECT(_expected, _expected_str, _seen, _seen_str, _t, _assert) do { \
757757
/* Avoid multiple evaluation of the cases */ \
758758
__typeof__(_expected) __exp = (_expected); \
759759
__typeof__(_seen) __seen = (_seen); \
760760
if (!(__exp _t __seen)) { \
761761
/* Report with actual signedness to avoid weird output. */ \
762-
switch (is_signed_type(__exp) * 2 + is_signed_type(__seen)) { \
762+
switch (is_signed_var(__exp) * 2 + is_signed_var(__seen)) { \
763763
case 0: { \
764764
uintmax_t __exp_print = (uintmax_t)__exp; \
765765
uintmax_t __seen_print = (uintmax_t)__seen; \

0 commit comments

Comments
 (0)