[glib] gtestutils: Explicitly cast args to g_assertion_message_cmpnum()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gtestutils: Explicitly cast args to g_assertion_message_cmpnum()
- Date: Mon, 2 Oct 2017 14:33:03 +0000 (UTC)
commit 702b6af87cbb61bad64dcbef0be893f1560db018
Author: Philip Withnall <withnall endlessm com>
Date: Sun Oct 1 00:49:22 2017 +0100
gtestutils: Explicitly cast args to g_assertion_message_cmpnum()
This avoids warnings when compiling with -Wconversion on 32-bit
architectures, as the conversion to (long double) is not necessarily
lossless. We don’t care about that, though, since the actual comparison
was done with the correct types, and g_assertion_message_cmpnum() is
only used to print failure information.
Signed-off-by: Philip Withnall <withnall endlessm com>
https://bugzilla.gnome.org/show_bug.cgi?id=788385
glib/gtestutils.h | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/glib/gtestutils.h b/glib/gtestutils.h
index 2a9cd22..e120562 100644
--- a/glib/gtestutils.h
+++ b/glib/gtestutils.h
@@ -48,32 +48,33 @@ typedef void (*GTestFixtureFunc) (gpointer fixture,
gint64 __n1 = (n1), __n2 = (n2); \
if (__n1 cmp __n2) ; else \
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__,
G_STRFUNC, \
- #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'i'); \
+ #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long
double) __n2, 'i'); \
} G_STMT_END
#define g_assert_cmpuint(n1, cmp, n2) G_STMT_START { \
guint64 __n1 = (n1), __n2 = (n2); \
if (__n1 cmp __n2) ; else \
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__,
G_STRFUNC, \
- #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'i'); \
+ #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long
double) __n2, 'i'); \
} G_STMT_END
#define g_assert_cmphex(n1, cmp, n2) G_STMT_START {\
guint64 __n1 = (n1), __n2 = (n2); \
if (__n1 cmp __n2) ; else \
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__,
G_STRFUNC, \
- #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'x'); \
+ #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long
double) __n2, 'x'); \
} G_STMT_END
#define g_assert_cmpfloat(n1,cmp,n2) G_STMT_START { \
long double __n1 = (n1), __n2 = (n2); \
if (__n1 cmp __n2) ; else \
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__,
G_STRFUNC, \
- #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'f'); \
+ #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long
double) __n2, 'f'); \
} G_STMT_END
#define g_assert_cmpmem(m1, l1, m2, l2) G_STMT_START {\
gconstpointer __m1 = m1, __m2 = m2; \
int __l1 = l1, __l2 = l2; \
if (__l1 != __l2) \
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__,
G_STRFUNC, \
- #l1 " (len(" #m1 ")) == " #l2 "
(len(" #m2 "))", __l1, "==", __l2, 'i'); \
+ #l1 " (len(" #m1 ")) == " #l2 "
(len(" #m2 "))", \
+ (long double) __l1, "==", (long
double) __l2, 'i'); \
else if (__l1 != 0 && memcmp (__m1, __m2, __l1) != 0) \
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__,
G_STRFUNC, \
"assertion failed (" #m1 " == " #m2
")"); \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]