mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-08 13:36:22 +01:00
gtestutils: Add some explicit double casts
This avoids some false positive warnings from `-Wfloat-conversion`. The code in `gtestutils.c` is a bit odd: it uses an array of `long double` elements, with specific indices of that array storing specific meaningful numbers, each of which has a type which is representable as a `long double`, but which actually isn’t. This is a prime candidate for refactoring to not use such a type-unsafe API where everything is marshalled through `long double`. Unfortunately, the array is declared in `GTestLogMsg`, which is defined in the public `gtestutils.h` header, so we can’t change it. Boo. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #3405
This commit is contained in:
parent
d0cba9e6ec
commit
412aed7c70
@ -747,9 +747,9 @@ static GPrintFunc g_default_print_func = NULL;
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
G_TEST_CASE_LARGS_RESULT = 0,
|
G_TEST_CASE_LARGS_RESULT = 0, /* a GTestResult */
|
||||||
G_TEST_CASE_LARGS_RUN_FORKS = 1,
|
G_TEST_CASE_LARGS_RUN_FORKS = 1, /* a gint */
|
||||||
G_TEST_CASE_LARGS_EXECUTION_TIME = 2,
|
G_TEST_CASE_LARGS_EXECUTION_TIME = 2, /* a gdouble */
|
||||||
|
|
||||||
G_TEST_CASE_LARGS_MAX
|
G_TEST_CASE_LARGS_MAX
|
||||||
};
|
};
|
||||||
@ -974,7 +974,7 @@ g_test_log (GTestLogType lbit,
|
|||||||
break;
|
break;
|
||||||
case G_TEST_LOG_STOP_CASE:
|
case G_TEST_LOG_STOP_CASE:
|
||||||
result = largs[G_TEST_CASE_LARGS_RESULT];
|
result = largs[G_TEST_CASE_LARGS_RESULT];
|
||||||
timing = largs[G_TEST_CASE_LARGS_EXECUTION_TIME];
|
timing = (gdouble) largs[G_TEST_CASE_LARGS_EXECUTION_TIME];
|
||||||
fail = result == G_TEST_RUN_FAILURE;
|
fail = result == G_TEST_RUN_FAILURE;
|
||||||
if (test_tap_log)
|
if (test_tap_log)
|
||||||
{
|
{
|
||||||
@ -4373,7 +4373,7 @@ g_test_log_dump (GTestLogMsg *msg,
|
|||||||
g_string_append_len (gstring, msg->strings[ui], l);
|
g_string_append_len (gstring, msg->strings[ui], l);
|
||||||
}
|
}
|
||||||
for (ui = 0; ui < msg->n_nums; ui++)
|
for (ui = 0; ui < msg->n_nums; ui++)
|
||||||
gstring_append_double (gstring, msg->nums[ui]);
|
gstring_append_double (gstring, (gdouble) msg->nums[ui]);
|
||||||
*len = gstring->len;
|
*len = gstring->len;
|
||||||
gstring_overwrite_int (gstring, 0, *len); /* message length */
|
gstring_overwrite_int (gstring, 0, *len); /* message length */
|
||||||
return (guint8*) g_string_free (gstring, FALSE);
|
return (guint8*) g_string_free (gstring, FALSE);
|
||||||
|
Loading…
Reference in New Issue
Block a user