selftests: harness: fix printing of mismatch values in __EXPECT()

intptr_t and uintptr_t are not big enough types on 32-bit architectures
when printing 64-bit values, resulting to the following incorrect
diagnostic output:

  # get_syscall_info.c:209:get_syscall_info:Expected exp_args[2] (3134324433) == info.entry.args[1] (3134324433)

Replace intptr_t and uintptr_t with intmax_t and uintmax_t, respectively.
With this fix, the same test produces more usable diagnostic output:

  # get_syscall_info.c:209:get_syscall_info:Expected exp_args[2] (3134324433) == info.entry.args[1] (18446744072548908753)

Link: https://lore.kernel.org/r/20250108170757.GA6723@strace.io
Fixes: b5bb6d3068 ("selftests/seccomp: fix 32-bit build warnings")
Signed-off-by: Dmitry V. Levin <ldv@strace.io>
Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
Dmitry V. Levin 2025-01-08 19:07:57 +02:00 committed by Shuah Khan
parent b6f9cd83c6
commit 02bc220dc6
1 changed files with 12 additions and 12 deletions

View File

@ -760,33 +760,33 @@
/* Report with actual signedness to avoid weird output. */ \ /* Report with actual signedness to avoid weird output. */ \
switch (is_signed_type(__exp) * 2 + is_signed_type(__seen)) { \ switch (is_signed_type(__exp) * 2 + is_signed_type(__seen)) { \
case 0: { \ case 0: { \
unsigned long long __exp_print = (uintptr_t)__exp; \ uintmax_t __exp_print = (uintmax_t)__exp; \
unsigned long long __seen_print = (uintptr_t)__seen; \ uintmax_t __seen_print = (uintmax_t)__seen; \
__TH_LOG("Expected %s (%llu) %s %s (%llu)", \ __TH_LOG("Expected %s (%ju) %s %s (%ju)", \
_expected_str, __exp_print, #_t, \ _expected_str, __exp_print, #_t, \
_seen_str, __seen_print); \ _seen_str, __seen_print); \
break; \ break; \
} \ } \
case 1: { \ case 1: { \
unsigned long long __exp_print = (uintptr_t)__exp; \ uintmax_t __exp_print = (uintmax_t)__exp; \
long long __seen_print = (intptr_t)__seen; \ intmax_t __seen_print = (intmax_t)__seen; \
__TH_LOG("Expected %s (%llu) %s %s (%lld)", \ __TH_LOG("Expected %s (%ju) %s %s (%jd)", \
_expected_str, __exp_print, #_t, \ _expected_str, __exp_print, #_t, \
_seen_str, __seen_print); \ _seen_str, __seen_print); \
break; \ break; \
} \ } \
case 2: { \ case 2: { \
long long __exp_print = (intptr_t)__exp; \ intmax_t __exp_print = (intmax_t)__exp; \
unsigned long long __seen_print = (uintptr_t)__seen; \ uintmax_t __seen_print = (uintmax_t)__seen; \
__TH_LOG("Expected %s (%lld) %s %s (%llu)", \ __TH_LOG("Expected %s (%jd) %s %s (%ju)", \
_expected_str, __exp_print, #_t, \ _expected_str, __exp_print, #_t, \
_seen_str, __seen_print); \ _seen_str, __seen_print); \
break; \ break; \
} \ } \
case 3: { \ case 3: { \
long long __exp_print = (intptr_t)__exp; \ intmax_t __exp_print = (intmax_t)__exp; \
long long __seen_print = (intptr_t)__seen; \ intmax_t __seen_print = (intmax_t)__seen; \
__TH_LOG("Expected %s (%lld) %s %s (%lld)", \ __TH_LOG("Expected %s (%jd) %s %s (%jd)", \
_expected_str, __exp_print, #_t, \ _expected_str, __exp_print, #_t, \
_seen_str, __seen_print); \ _seen_str, __seen_print); \
break; \ break; \