[LTP] tst_assert: Use 'long long' to fix 32bit compat mode truncation
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Fri Sep 18 19:06:42 CEST 2026
Hi Andrea,
On Fri, 18 Sep 2026, Andrea Cervesato wrote:
> [PATCH 1/2] tst_assert: Use 'long long' to fix 32bit compat mode truncation
--- [PATCH 1/2] ---
> - 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);
Casting sys_val to unsigned long causes false passes on 32-bit systems
whenever sys_val exceeds ULONG_MAX and (sys_val & 0xFFFFFFFF) equals val,
while masking the actual value read in the failure log. Compare
val == sys_val directly and report sys_val with %llu on mismatch;
compat-mode truncation should be handled in test-specific code instead of
altering generic assertion semantics.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list