mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 10:40:58 +01:00
tests: minor code cleanup of nmtst_main_loop_run()
This commit is contained in:
parent
34122c874e
commit
11fedad544
1 changed files with 5 additions and 12 deletions
|
|
@ -921,33 +921,26 @@ _nmtst_main_loop_run_timeout (gpointer user_data)
|
|||
{
|
||||
GMainLoop **p_loop = user_data;
|
||||
|
||||
g_assert (p_loop);
|
||||
g_assert (*p_loop);
|
||||
|
||||
g_main_loop_quit (*p_loop);
|
||||
*p_loop = NULL;
|
||||
|
||||
g_assert (p_loop && *p_loop);
|
||||
g_main_loop_quit (g_steal_pointer (p_loop));
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
nmtst_main_loop_run (GMainLoop *loop, guint timeout_ms)
|
||||
{
|
||||
GSource *source = NULL;
|
||||
guint id = 0;
|
||||
nm_auto_unref_gsource GSource *source = NULL;
|
||||
GMainLoop *loopx = loop;
|
||||
|
||||
if (timeout_ms > 0) {
|
||||
source = g_timeout_source_new (timeout_ms);
|
||||
g_source_set_callback (source, _nmtst_main_loop_run_timeout, &loopx, NULL);
|
||||
id = g_source_attach (source, g_main_loop_get_context (loop));
|
||||
g_assert (id);
|
||||
g_source_unref (source);
|
||||
g_source_attach (source, g_main_loop_get_context (loop));
|
||||
}
|
||||
|
||||
g_main_loop_run (loop);
|
||||
|
||||
if (source && loopx)
|
||||
if (source)
|
||||
g_source_destroy (source);
|
||||
|
||||
/* if the timeout was reached, return FALSE. */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue