[glib: 1/5] gdbusauthmechanismsha1: Remove unnecessary g_warning() calls
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/5] gdbusauthmechanismsha1: Remove unnecessary g_warning() calls
- Date: Tue, 29 Oct 2019 08:37:49 +0000 (UTC)
commit ef3eec8a2876691a71574d871668283ae8d379b7
Author: Philip Withnall <withnall endlessm com>
Date: Mon Oct 28 19:13:50 2019 +0000
gdbusauthmechanismsha1: Remove unnecessary g_warning() calls
These can be hit in the tests (if multiple tests run in parallel are
racing for `~/.dbus-keyrings/org_gtk_gdbus_general.lock` for a prolonged
period) and will cause spurious test failures due to the use of
`G_DEBUG=fatal-warnings`.
Instead, allow the error messages to be inspected programmatically.
Signed-off-by: Philip Withnall <withnall endlessm com>
Helps: #1912
gio/gdbusauthmechanismsha1.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/gio/gdbusauthmechanismsha1.c b/gio/gdbusauthmechanismsha1.c
index 553bcdc32..d29048ad7 100644
--- a/gio/gdbusauthmechanismsha1.c
+++ b/gio/gdbusauthmechanismsha1.c
@@ -48,6 +48,7 @@ struct _GDBusAuthMechanismSha1Private
gboolean is_client;
gboolean is_server;
GDBusAuthMechanismState state;
+ gchar *reject_reason; /* non-NULL iff (state == G_DBUS_AUTH_MECHANISM_STATE_REJECTED) */
/* used on the client side */
gchar *to_send;
@@ -101,6 +102,7 @@ _g_dbus_auth_mechanism_sha1_finalize (GObject *object)
{
GDBusAuthMechanismSha1 *mechanism = G_DBUS_AUTH_MECHANISM_SHA1 (object);
+ g_free (mechanism->priv->reject_reason);
g_free (mechanism->priv->to_send);
g_free (mechanism->priv->cookie);
@@ -963,7 +965,8 @@ mechanism_server_data_receive (GDBusAuthMechanism *mechanism,
tokens = g_strsplit (data, " ", 0);
if (g_strv_length (tokens) != 2)
{
- g_warning ("Malformed data '%s'", data);
+ g_free (m->priv->reject_reason);
+ m->priv->reject_reason = g_strdup_printf ("Malformed data '%s'", data);
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
}
@@ -979,6 +982,8 @@ mechanism_server_data_receive (GDBusAuthMechanism *mechanism,
}
else
{
+ g_free (m->priv->reject_reason);
+ m->priv->reject_reason = g_strdup_printf ("SHA-1 mismatch");
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
}
@@ -1014,7 +1019,8 @@ mechanism_server_data_send (GDBusAuthMechanism *mechanism,
&m->priv->cookie,
&error))
{
- g_warning ("Error adding entry to keyring: %s", error->message);
+ g_free (m->priv->reject_reason);
+ m->priv->reject_reason = g_strdup_printf ("Error adding entry to keyring: %s", error->message);
g_error_free (error);
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
@@ -1042,10 +1048,7 @@ mechanism_server_get_reject_reason (GDBusAuthMechanism *mechanism)
g_return_val_if_fail (m->priv->is_server && !m->priv->is_client, NULL);
g_return_val_if_fail (m->priv->state == G_DBUS_AUTH_MECHANISM_STATE_REJECTED, NULL);
- /* can never end up here because we are never in the REJECTED state */
- g_assert_not_reached ();
-
- return NULL;
+ return g_strdup (m->priv->reject_reason);
}
static void
@@ -1128,7 +1131,8 @@ mechanism_client_data_receive (GDBusAuthMechanism *mechanism,
tokens = g_strsplit (data, " ", 0);
if (g_strv_length (tokens) != 3)
{
- g_warning ("Malformed data '%s'", data);
+ g_free (m->priv->reject_reason);
+ m->priv->reject_reason = g_strdup_printf ("Malformed data '%s'", data);
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
}
@@ -1137,7 +1141,8 @@ mechanism_client_data_receive (GDBusAuthMechanism *mechanism,
cookie_id = g_ascii_strtoll (tokens[1], &endp, 10);
if (*endp != '\0')
{
- g_warning ("Malformed cookie_id '%s'", tokens[1]);
+ g_free (m->priv->reject_reason);
+ m->priv->reject_reason = g_strdup_printf ("Malformed cookie_id '%s'", tokens[1]);
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
}
@@ -1147,7 +1152,8 @@ mechanism_client_data_receive (GDBusAuthMechanism *mechanism,
cookie = keyring_lookup_entry (cookie_context, cookie_id, &error);
if (cookie == NULL)
{
- g_warning ("Problems looking up entry in keyring: %s", error->message);
+ g_free (m->priv->reject_reason);
+ m->priv->reject_reason = g_strdup_printf ("Problems looking up entry in keyring: %s", error->message);
g_error_free (error);
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]