[LTP] [PATCH 1/2] tst_assert: Use 'long long' to fix 32bit compat mode truncation
Petr Vorel
pvorel@suse.cz
Fri Sep 18 14:50:20 CEST 2026
From: Andrea Cervesato <andrea.cervesato@suse.com>
Using 'long long' in tst_assert_ulong() correctly verifies values on
32bit compat mode truncation.
This fixes failure of shmctl03.c on /proc/sys/kernel/shmall on 32bit
(potentially on other sysfs files).
Reported-by: Wei Gao <wegao@suse.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
[ pvorel: separate into its own commit, write the commit message ]
Co-developed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/tst_assert.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/tst_assert.c b/lib/tst_assert.c
index b68bd5d397..5a4896ac52 100644
--- a/lib/tst_assert.c
+++ b/lib/tst_assert.c
@@ -25,16 +25,17 @@ void tst_assert_int(const char *file, const int lineno, const char *path, int va
void tst_assert_ulong(const char *file, const int lineno, const char *path, unsigned long val)
{
- unsigned long sys_val;
+ unsigned long long sys_val;
- safe_file_scanf(file, lineno, NULL, path, "%lu", &sys_val);
+ safe_file_scanf(file, lineno, NULL, path, "%llu", &sys_val);
- if (val == sys_val) {
+ if (val == (unsigned long)sys_val) {
tst_res_(file, lineno, TPASS, "%s = %lu", path, val);
return;
}
- tst_res_(file, lineno, TFAIL, "%s != %lu got %lu", path, val, sys_val);
+ tst_res_(file, lineno, TFAIL, "%s != %lu got %lu",
+ path, val, (unsigned long)sys_val);
}
void tst_assert_file_int(const char *file, const int lineno, const char *path, const char *prefix, int val)
--
2.55.0
More information about the ltp
mailing list