mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
gtestutils: Fix a sign-conversion warning in g_assert_cmpmem()
It was assigning the two provided lengths to internal `int` variables. Given that memory block lengths are typically a `size_t`, this will usually result in a warning if `-Wsign-conversion` is enabled. Given that the internal variables are passed to `memcmp()`, which takes `size_t`, change them to `size_t` and add an explicit cast to avoid warnings in future. The alternative would be to mess around with defining `__l1` and `__l2` to using `typeof()`, but that would lead to a complete mess with the printf placeholders and probably cause more problems than it fixes. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #2919
This commit is contained in:
parent
39eea23825
commit
d2d1af284d
@ -82,7 +82,7 @@ typedef void (*GTestFixtureFunc) (gpointer fixture,
|
||||
} G_STMT_END
|
||||
#define g_assert_cmpmem(m1, l1, m2, l2) G_STMT_START {\
|
||||
gconstpointer __m1 = m1, __m2 = m2; \
|
||||
int __l1 = l1, __l2 = l2; \
|
||||
size_t __l1 = (size_t) l1, __l2 = (size_t) l2; \
|
||||
if (__l1 != 0 && __m1 == NULL) \
|
||||
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||
"assertion failed (" #l1 " == 0 || " #m1 " != NULL)"); \
|
||||
|
Loading…
Reference in New Issue
Block a user