From e888e7d497c50f36d533e2efc43552720e1dd5db Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 17 Sep 2024 23:36:48 +0100 Subject: [PATCH 1/2] =?UTF-8?q?tests:=20Add=20some=20explicit=20float=20?= =?UTF-8?q?=E2=86=92=20int=20casts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids some false positive warnings from `-Wfloat-conversion`. Signed-off-by: Philip Withnall --- gio/tests/socket.c | 2 +- glib/tests/testing.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gio/tests/socket.c b/gio/tests/socket.c index 7408ebe71..5d3278e0f 100644 --- a/gio/tests/socket.c +++ b/gio/tests/socket.c @@ -837,7 +837,7 @@ cancellable_thread_cb (gpointer data) { GCancellable *cancellable = data; - g_usleep (0.1 * G_USEC_PER_SEC); + g_usleep ((guint64) (0.1 * G_USEC_PER_SEC)); g_cancellable_cancel (cancellable); g_object_unref (cancellable); diff --git a/glib/tests/testing.c b/glib/tests/testing.c index 8a49e69aa..0b6633700 100644 --- a/glib/tests/testing.c +++ b/glib/tests/testing.c @@ -330,7 +330,7 @@ static void test_fork_timeout (void) { /* allow child to run for only a fraction of a second */ - if (g_test_trap_fork (0.11 * 1000000, G_TEST_TRAP_DEFAULT)) + if (g_test_trap_fork ((guint64) (0.11 * G_USEC_PER_SEC), G_TEST_TRAP_DEFAULT)) { /* loop and sleep forever */ while (TRUE) @@ -399,7 +399,7 @@ test_subprocess_timeout (void) return; } /* allow child to run for only a fraction of a second */ - g_test_trap_subprocess (NULL, 0.05 * G_USEC_PER_SEC, G_TEST_SUBPROCESS_DEFAULT); + g_test_trap_subprocess (NULL, (guint64) (0.05 * G_USEC_PER_SEC), G_TEST_SUBPROCESS_DEFAULT); g_test_trap_assert_failed (); g_assert_true (g_test_trap_reached_timeout ()); } From 9cb0e9464e6117c4ff84b648851c6ee2f5873d1b Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 17 Sep 2024 23:42:31 +0100 Subject: [PATCH 2/2] gapplication: Fix a -Wfloat-conversion warning This introduces no functional changes, but does squash a false positive warning from `-Wfloat-conversion`: ``` ../gio/gapplication.c:462:15: error: implicit conversion turns floating-point number into integer: 'gdouble' (aka 'double') to '_Bool' [-Werror,-Wfloat-conversion] if (*(gdouble *) entry->arg_data) ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. ``` Signed-off-by: Philip Withnall --- gio/gapplication.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gio/gapplication.c b/gio/gapplication.c index 112829fce..d649e4539 100644 --- a/gio/gapplication.c +++ b/gio/gapplication.c @@ -459,7 +459,7 @@ g_application_pack_option_entries (GApplication *application, break; case G_OPTION_ARG_DOUBLE: - if (*(gdouble *) entry->arg_data) + if (*(gdouble *) entry->arg_data != 0.0) value = g_variant_new_double (*(gdouble *) entry->arg_data); break;