[LTP] tst_assert: Use 'long long' to fix 32bit compat mode truncation
Petr Vorel
pvorel@suse.cz
Tue Sep 22 09:35:19 CEST 2026
Hi all,
> 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.
I don't understand why casting is problem when the original code used unsigned
long for sys_val.
- unsigned long sys_val;
+ unsigned long long sys_val;
=> I would say agent is wrong.
But the suggestion to modify the behavior for all tests due single 32bit mode
failure is something to be considered.
@Li @Cyril WDYT? Is this patchset safe, or we use the one contributed by Wei?
Other option would be to handle everything with custom code in shmctl03.c
(wait for library helper until it's really needed).
Also, if we change tst_assert(), do we want to somehow document in the kerneldoc
that code is ready for 32bit?
Kind regards,
Petr
> 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