diff options
author | Thomas Haller <thaller@redhat.com> | 2020-04-29 09:48:52 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-04-30 13:57:39 +0200 |
commit | d69888f3397bcb18074523a46196ffb0b0f6337a (patch) | |
tree | 9b66f23d105a3c5a980dc81739c6bd7345c8d321 | |
parent | 6e3dc17d0d314b433e549e9a8c70270a3dd046c3 (diff) | |
download | NetworkManager-th/dispatcher-doc-connectivity-change-arg.tar.gz |
dispatcher: minor cleanup error paths in script_dispatch()th/dispatcher-doc-connectivity-change-arg
Handle the error case first and return early.
-rw-r--r-- | dispatcher/nm-dispatcher.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/dispatcher/nm-dispatcher.c b/dispatcher/nm-dispatcher.c index 55656cf7b5..e1737d85ff 100644 --- a/dispatcher/nm-dispatcher.c +++ b/dispatcher/nm-dispatcher.c @@ -482,7 +482,7 @@ check_filename (const char *file_name) static gboolean script_dispatch (ScriptInfo *script) { - GError *error = NULL; + gs_free_error GError *error = NULL; char *argv[4]; Request *request = script->request; @@ -502,20 +502,19 @@ script_dispatch (ScriptInfo *script) _LOG_S_T (script, "run script%s", script->wait ? "" : " (no-wait)"); - if (g_spawn_async ("/", argv, request->envp, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &script->pid, &error)) { - script->watch_id = g_child_watch_add (script->pid, (GChildWatchFunc) script_watch_cb, script); - script->timeout_id = g_timeout_add_seconds (SCRIPT_TIMEOUT, script_timeout_cb, script); - if (!script->wait) - request->num_scripts_nowait++; - return TRUE; - } else { + if (!g_spawn_async ("/", argv, request->envp, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &script->pid, &error)) { _LOG_S_W (script, "complete: failed to execute script: %s", error->message); script->result = DISPATCH_RESULT_EXEC_FAILED; script->error = g_strdup (error->message); request->num_scripts_done++; - g_clear_error (&error); return FALSE; } + + script->watch_id = g_child_watch_add (script->pid, (GChildWatchFunc) script_watch_cb, script); + script->timeout_id = g_timeout_add_seconds (SCRIPT_TIMEOUT, script_timeout_cb, script); + if (!script->wait) + request->num_scripts_nowait++; + return TRUE; } static gboolean |