Skip to content

Conversation

@pks-gitlab
Copy link

In #117 we have introduced type-safe wrappers for integer comparison functions. This wrapper introduces an issue though where arguments are getting evaluated twice now. This PR here fixes that bug.

pks-t added 4 commits December 5, 2025 09:06
Variadic macros always expect at least one argument. Consequently, when
one wants to declare a macro that takes a formatting string and an
optional list of varibles then one cannot declare the formatting string
itself as a separate argument to the function.

In the newly introduced integer comparison functions we do exactly that
though. Consequently, all callers must pass at least one variable to the
formatting string, even if they don't want to use any formatting in the
first place.

Fix this by dropping the explicit formatting string parameter. Add tests
to catch this issue going forward.
The `cl_assert_eq_i()` function has been newly introduced with the
typesafe integer comparison functions. This function and its cousin
`cl_assert_eq_i_()` are so similar to the preexisting functions
`cl_assert_equal_i()` and `cl_assert_equal_i_()` to cause some
confusion.

The only difference is the exact output format. So let's merge those two
and drop the newly introduced functions again. Also rename equivalent
functions for unsigned integers to match.
The error message that we use for all the integer comparison functions
is repeated for every macro. This was done because we reused the same
infra for both deprecated comparison functions (`cl_assert_equal_i()`)
and the new replacements (`cl_assert_eq_i()`), and the resulting error
messages are expected to be different there.

That has changed in the preceding commit though, where we started to
open-code the deprecated functions. Consequently, we can now deduplicate
the error message for the new comparison functions.

Do so.
Same as with a preceding comimt we also have double evaluation of
arguments in the newly introduced integer comparison macros. Fix this
issue by storing the values in a local variable first.
@pks-gitlab pks-gitlab force-pushed the pks-integer-double-evaluation branch from 55dd71a to db09c85 Compare December 5, 2025 10:08
@pks-t pks-t merged commit 39f11fe into clar-test:main Dec 5, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants