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.
This commit is contained in:
Thomas Haller 2023-05-17 08:15:16 +02:00
parent 30b5418608
commit cdda194844
5 changed files with 2 additions and 7 deletions

View File

@ -4003,8 +4003,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;

View File

@ -135,8 +135,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);

View File

@ -709,8 +709,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);

View File

@ -5510,7 +5510,6 @@ g_child_watch_prepare (GSource *source,
gint *timeout)
{
#ifdef G_OS_WIN32
*timeout = -1;
return FALSE;
#else /* G_OS_WIN32 */
{

View File

@ -37,6 +37,8 @@ cb (gpointer data)
static gboolean
prepare (GSource *source, gint *time)
{
g_assert_nonnull (time);
g_assert_cmpint (*time, ==, -1);
return FALSE;
}
static gboolean