From c2b60e0323d09a91a26b69249a619f3ed8cbad8d Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:30:49 +0100 Subject: [PATCH 01/10] Fix redefinition of local variable in gio/gdbusconnection.c --- gio/gdbusconnection.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c index bd82ab3bb..fe52cfcb5 100644 --- a/gio/gdbusconnection.c +++ b/gio/gdbusconnection.c @@ -5977,11 +5977,11 @@ g_dbus_connection_call_internal (GDBusConnection *connection, } else { - GDBusMessageFlags flags; + GDBusMessageFlags msg_flags; - flags = g_dbus_message_get_flags (message); - flags |= G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED; - g_dbus_message_set_flags (message, flags); + msg_flags = g_dbus_message_get_flags (message); + msg_flags |= G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED; + g_dbus_message_set_flags (message, msg_flags); g_dbus_connection_send_message (connection, message, From eb157bfa1b975b7ba9a8fa4a4aeb10903d946ed0 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:30:29 +0100 Subject: [PATCH 02/10] Fix redefinition of local variable in gio/gdbusauthmechanismsha1.c --- gio/gdbusauthmechanismsha1.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gio/gdbusauthmechanismsha1.c b/gio/gdbusauthmechanismsha1.c index 8137b6352..b10e537c5 100644 --- a/gio/gdbusauthmechanismsha1.c +++ b/gio/gdbusauthmechanismsha1.c @@ -660,7 +660,7 @@ keyring_generate_entry (const gchar *cookie_context, gchar *keyring_dir; gchar *path; gchar *contents; - GError *local_error; + GError *local_error = NULL; gchar **lines; gint max_line_id; GString *new_contents; @@ -696,7 +696,6 @@ keyring_generate_entry (const gchar *cookie_context, if (lock_fd == -1) goto out; - local_error = NULL; contents = NULL; if (!g_file_get_contents (path, &contents, @@ -706,12 +705,12 @@ keyring_generate_entry (const gchar *cookie_context, if (local_error->domain == G_FILE_ERROR && local_error->code == G_FILE_ERROR_NOENT) { /* file doesn't have to exist */ - g_error_free (local_error); + g_clear_error (&local_error); } else { g_propagate_prefixed_error (error, - local_error, + g_steal_pointer (&local_error), _("Error opening keyring ā€œ%sā€ for writing: "), path); goto out; @@ -890,11 +889,11 @@ keyring_generate_entry (const gchar *cookie_context, } out: + /* Any error should have been propagated to @error by now */ + g_assert (local_error == NULL); if (lock_fd != -1) { - GError *local_error; - local_error = NULL; if (!keyring_release_lock (path, lock_fd, &local_error)) { if (error != NULL) From 4bcb7bc6312a6d53b8b546accc3aa82d88fa4664 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:30:06 +0100 Subject: [PATCH 03/10] Fix redefinition of local variable in gio/gdbusauth.c --- gio/gdbusauth.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c index 74c178dbf..7a7900c1b 100644 --- a/gio/gdbusauth.c +++ b/gio/gdbusauth.c @@ -461,7 +461,6 @@ client_choose_mech_and_send_initial_response (GDBusAuth *auth, if (auth_mech_to_use_gtype == (GType) 0) { - guint n; gchar *available; GString *tried_str; From 0c1619227c0c06f5c61270578f3791f90ae69cd5 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:29:49 +0100 Subject: [PATCH 04/10] Fix redefinition of local variable in gio/gdbus-tool.c --- gio/gdbus-tool.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gio/gdbus-tool.c b/gio/gdbus-tool.c index 42991886a..15533b075 100644 --- a/gio/gdbus-tool.c +++ b/gio/gdbus-tool.c @@ -1247,19 +1247,19 @@ handle_call (gint *argc, { if (in_signature_types->len > 0) { - GString *s; - s = g_string_new (NULL); + GString *str; + str = g_string_new (NULL); for (n = 0; n < in_signature_types->len; n++) { GVariantType *type = in_signature_types->pdata[n]; - g_string_append_len (s, + g_string_append_len (str, g_variant_type_peek_string (type), g_variant_type_get_string_length (type)); } - g_printerr ("(According to introspection data, you need to pass '%s')\n", s->str); - g_string_free (s, TRUE); + g_printerr ("(According to introspection data, you need to pass '%s')\n", str->str); + g_string_free (str, TRUE); } else g_printerr ("(According to introspection data, you need to pass no arguments)\n"); @@ -1531,7 +1531,6 @@ dump_interface (GDBusConnection *c, } else { - guint n; for (n = 0; o->properties != NULL && o->properties[n] != NULL; n++) { result = g_dbus_connection_call_sync (c, From 3214a0f3334fc8ca2f130795953ceb32414d8c4d Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:29:13 +0100 Subject: [PATCH 05/10] Fix redefinition of local variable in gio/gapplicationimpl-dbus.c --- gio/gapplicationimpl-dbus.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gio/gapplicationimpl-dbus.c b/gio/gapplicationimpl-dbus.c index 5604b9260..da4d17ea6 100644 --- a/gio/gapplicationimpl-dbus.c +++ b/gio/gapplicationimpl-dbus.c @@ -376,20 +376,20 @@ g_application_impl_attempt_primary (GApplicationImpl *impl, if (org_gtk_Application == NULL) { - GError *error = NULL; + GError *my_error = NULL; GDBusNodeInfo *info; - info = g_dbus_node_info_new_for_xml (org_gtk_Application_xml, &error); + info = g_dbus_node_info_new_for_xml (org_gtk_Application_xml, &my_error); if G_UNLIKELY (info == NULL) - g_error ("%s", error->message); + g_error ("%s", my_error->message); org_gtk_Application = g_dbus_node_info_lookup_interface (info, "org.gtk.Application"); g_assert (org_gtk_Application != NULL); g_dbus_interface_info_ref (org_gtk_Application); g_dbus_node_info_unref (info); - info = g_dbus_node_info_new_for_xml (org_freedesktop_Application_xml, &error); + info = g_dbus_node_info_new_for_xml (org_freedesktop_Application_xml, &my_error); if G_UNLIKELY (info == NULL) - g_error ("%s", error->message); + g_error ("%s", my_error->message); org_freedesktop_Application = g_dbus_node_info_lookup_interface (info, "org.freedesktop.Application"); g_assert (org_freedesktop_Application != NULL); g_dbus_interface_info_ref (org_freedesktop_Application); From c324ce5c2abdbbffbb673e0d7774312416e51d95 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:28:46 +0100 Subject: [PATCH 06/10] Fix redefinition of local variable in gio/gactiongroupexporter.c --- gio/gactiongroupexporter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gio/gactiongroupexporter.c b/gio/gactiongroupexporter.c index d1c1903e8..28f018f8b 100644 --- a/gio/gactiongroupexporter.c +++ b/gio/gactiongroupexporter.c @@ -545,12 +545,12 @@ g_dbus_connection_export_action_group (GDBusConnection *connection, if G_UNLIKELY (org_gtk_Actions == NULL) { - GError *error = NULL; + GError *my_error = NULL; GDBusNodeInfo *info; - info = g_dbus_node_info_new_for_xml (org_gtk_Actions_xml, &error); + info = g_dbus_node_info_new_for_xml (org_gtk_Actions_xml, &my_error); if G_UNLIKELY (info == NULL) - g_error ("%s", error->message); + g_error ("%s", my_error->message); org_gtk_Actions = g_dbus_node_info_lookup_interface (info, "org.gtk.Actions"); g_assert (org_gtk_Actions != NULL); g_dbus_interface_info_ref (org_gtk_Actions); From 7178e10cd5aeadb6e5cb6a29a49cbb731097a525 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:28:17 +0100 Subject: [PATCH 07/10] Fix redefinition of local variable in gio/tests/testfilemonitor.c --- gio/tests/testfilemonitor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gio/tests/testfilemonitor.c b/gio/tests/testfilemonitor.c index a52ade715..2307f7463 100644 --- a/gio/tests/testfilemonitor.c +++ b/gio/tests/testfilemonitor.c @@ -235,12 +235,12 @@ check_expected_events (RecordedEvent *expected, * error messages. Print the expected and actual events first. */ else { - GList *l; + GList *ll; gsize j; g_test_message ("Recorded events:"); - for (l = recorded; l != NULL; l = l->next) - output_event ((RecordedEvent *) l->data); + for (ll = recorded; ll != NULL; ll = ll->next) + output_event ((RecordedEvent *) ll->data); g_test_message ("Expected events:"); for (j = 0; j < n_expected; j++) From 027e3769eea2a605afdf0bbd5f7cabcf81164336 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 14:45:49 +0100 Subject: [PATCH 08/10] Fix global variable name hidden by local variables in gio/tests/socket-server.c --- gio/tests/socket-server.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gio/tests/socket-server.c b/gio/tests/socket-server.c index 8b0d2a925..61715b02d 100644 --- a/gio/tests/socket-server.c +++ b/gio/tests/socket-server.c @@ -6,7 +6,7 @@ GMainLoop *loop; -int port = 7777; +int default_port = 7777; gboolean verbose = FALSE; gboolean dont_reuse_address = FALSE; gboolean non_blocking = FALSE; @@ -18,7 +18,7 @@ gboolean unix_socket = FALSE; const char *tls_cert_file = NULL; static GOptionEntry cmd_entries[] = { - {"port", 'p', 0, G_OPTION_ARG_INT, &port, + {"port", 'p', 0, G_OPTION_ARG_INT, &default_port, "Local port to bind to", NULL}, {"cancel", 'c', 0, G_OPTION_ARG_INT, &cancel_timeout, "Cancel any op after the specified amount of seconds", NULL}, @@ -51,7 +51,7 @@ main (int argc, { GSocket *socket, *new_socket, *recv_socket; GSocketAddress *src_address; - GSocketAddress *address; + GSocketAddress *address = NULL; GSocketType socket_type; GSocketFamily socket_family; GError *error = NULL; @@ -140,7 +140,7 @@ main (int argc, } else { - src_address = g_inet_socket_address_new (g_inet_address_new_any (G_SOCKET_FAMILY_IPV4), port); + src_address = g_inet_socket_address_new (g_inet_address_new_any (G_SOCKET_FAMILY_IPV4), default_port); } if (!g_socket_bind (socket, src_address, !dont_reuse_address, &error)) From 7bd79b112d0b4432bc87be0a3d4ce93492bf8519 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:56:56 +0100 Subject: [PATCH 09/10] Fix non-initialized variable in gio/tests/socket-client.c --- gio/tests/socket-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gio/tests/socket-client.c b/gio/tests/socket-client.c index 6c25e08c9..92bf41fb9 100644 --- a/gio/tests/socket-client.c +++ b/gio/tests/socket-client.c @@ -257,7 +257,7 @@ main (int argc, GIOStream *connection; GInputStream *istream; GOutputStream *ostream; - GSocketAddress *src_address; + GSocketAddress *src_address = NULL; GTlsCertificate *certificate = NULL; gint i; From e372ed3413ff847cb1ba14b731bf8e6f6fb7b66d Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 21:07:05 +0100 Subject: [PATCH 10/10] Fix cast pointer to int warning in gio/tests/socket.c --- gio/tests/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gio/tests/socket.c b/gio/tests/socket.c index 250ec648a..02605a6dc 100644 --- a/gio/tests/socket.c +++ b/gio/tests/socket.c @@ -1203,7 +1203,7 @@ duplicate_fd (int fd) return -1; } - return (int)newfd; + return (int)(gintptr)newfd; #else return dup (fd); #endif