summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-05-11 13:05:51 +0200
committerThomas Haller <thaller@redhat.com>2023-05-12 12:48:00 +0200
commit62d742625d369d2e329eab66934e0d522c07482a (patch)
tree1506f8ba4ec5a3b17e95fddc3f874aa7ddc6f23e
parentfe5dfe97f970cd358cbd06edb82f33d8ca207c59 (diff)
downloadNetworkManager-62d742625d369d2e329eab66934e0d522c07482a.tar.gz
tui: cleanup secrets_requested() function to use cleanup attribute
No explicit unref/free. Resources should be owned by somebody, like an auto variable with a cleanup attribute.
-rw-r--r--src/nmtui/nmtui-connect.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/nmtui/nmtui-connect.c b/src/nmtui/nmtui-connect.c
index 75862bbd90..0dfbf6ac20 100644
--- a/src/nmtui/nmtui-connect.c
+++ b/src/nmtui/nmtui-connect.c
@@ -34,7 +34,6 @@ secrets_requested(NMSecretAgentSimple *agent,
GPtrArray *secrets,
gpointer user_data)
{
- NmtNewtForm *form;
NMConnection *connection = NM_CONNECTION(user_data);
gboolean success = FALSE;
@@ -44,7 +43,7 @@ secrets_requested(NMSecretAgentSimple *agent,
if (nm_streq0(nm_setting_vpn_get_service_type(s_vpn),
NM_SECRET_AGENT_VPN_TYPE_OPENCONNECT)) {
- GError *error = NULL;
+ gs_free_error GError *error = NULL;
nmt_newt_message_dialog(_("openconnect will be run to authenticate.\nIt will return to "
"nmtui when completed."));
@@ -55,26 +54,21 @@ secrets_requested(NMSecretAgentSimple *agent,
newtResume();
- if (!success) {
+ if (!success)
nmt_newt_message_dialog(_("Error: openconnect failed: %s"), error->message);
- g_clear_error(&error);
- }
}
}
if (!success) {
+ gs_unref_object NmtNewtForm *form = NULL;
+
form = nmt_password_dialog_new(request_id, title, msg, secrets);
nmt_newt_form_run_sync(form);
success = nmt_password_dialog_succeeded(NMT_PASSWORD_DIALOG(form));
-
- g_object_unref(form);
}
- if (success)
- nm_secret_agent_simple_response(agent, request_id, secrets);
- else
- nm_secret_agent_simple_response(agent, request_id, NULL);
+ nm_secret_agent_simple_response(agent, request_id, success ? secrets : NULL);
}
typedef struct {