From b71ae65f14843cc09819e5b482667e5c941a27af Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 17 May 2023 08:15:16 +0200 Subject: [PATCH] gmain: remove unnecessary initialization of *timeout in prepare() callbacks Note that the prepare callback only has one caller, which pre-initializes the timeout argument to -1. That may be an implementation detail and not publicly promised, but it wouldn't make sense to do it any other way in the caller. Also, note that g_unix_signal_watch_prepare() and the UNIX branch of g_child_watch_prepare() already relied on that. --- gio/gsocket.c | 2 -- glib/giounix.c | 2 -- glib/giowin32.c | 2 -- glib/gmain.c | 1 - glib/tests/mainloop.c | 2 ++ 5 files changed, 2 insertions(+), 7 deletions(-) diff --git a/gio/gsocket.c b/gio/gsocket.c index f39a568b3..c624eb1ae 100644 --- a/gio/gsocket.c +++ b/gio/gsocket.c @@ -3955,8 +3955,6 @@ socket_source_prepare (GSource *source, { GSocketSource *socket_source = (GSocketSource *)source; - *timeout = -1; - #ifdef G_OS_WIN32 if ((socket_source->pollfd.revents & G_IO_NVAL) != 0) return TRUE; diff --git a/glib/giounix.c b/glib/giounix.c index b86d79db7..94b33253f 100644 --- a/glib/giounix.c +++ b/glib/giounix.c @@ -129,8 +129,6 @@ g_io_unix_prepare (GSource *source, GIOUnixWatch *watch = (GIOUnixWatch *)source; GIOCondition buffer_condition = g_io_channel_get_buffer_condition (watch->channel); - *timeout = -1; - /* Only return TRUE here if _all_ bits in watch->condition will be set */ return ((watch->condition & buffer_condition) == watch->condition); diff --git a/glib/giowin32.c b/glib/giowin32.c index b0b6c3d85..e4b171b0d 100644 --- a/glib/giowin32.c +++ b/glib/giowin32.c @@ -707,8 +707,6 @@ g_io_win32_prepare (GSource *source, GIOWin32Channel *channel = (GIOWin32Channel *)watch->channel; int event_mask; - *timeout = -1; - if (channel->debug) g_print ("g_io_win32_prepare: source=%p channel=%p", source, channel); diff --git a/glib/gmain.c b/glib/gmain.c index 28fbcc015..aec04314c 100644 --- a/glib/gmain.c +++ b/glib/gmain.c @@ -5245,7 +5245,6 @@ g_child_watch_prepare (GSource *source, gint *timeout) { #ifdef G_OS_WIN32 - *timeout = -1; return FALSE; #else /* G_OS_WIN32 */ { diff --git a/glib/tests/mainloop.c b/glib/tests/mainloop.c index d43b2cf08..a7c5b33d1 100644 --- a/glib/tests/mainloop.c +++ b/glib/tests/mainloop.c @@ -34,6 +34,8 @@ cb (gpointer data) static gboolean prepare (GSource *source, gint *time) { + g_assert_nonnull (time); + g_assert_cmpint (*time, ==, -1); return FALSE; } static gboolean