From e0ccf082842931fc2a39de16477434968a25813f Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:57:59 +0100 Subject: [PATCH 01/10] Fix non-initialized variable in gio/gsettings-tool.c --- gio/gsettings-tool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gio/gsettings-tool.c b/gio/gsettings-tool.c index 0c7763a39..9352b70f5 100644 --- a/gio/gsettings-tool.c +++ b/gio/gsettings-tool.c @@ -570,8 +570,8 @@ static int gsettings_help (gboolean requested, const gchar *command) { - const gchar *description; - const gchar *synopsis; + const gchar *description = NULL; + const gchar *synopsis = NULL; GString *string; string = g_string_new (NULL); From 37ca061e40f88557940f9547f4682629aa4e0130 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:50:24 +0100 Subject: [PATCH 02/10] Fix redefinition of local variable in gio/gsettings.c --- gio/gsettings.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gio/gsettings.c b/gio/gsettings.c index e96c94e11..c2c7bf71d 100644 --- a/gio/gsettings.c +++ b/gio/gsettings.c @@ -406,12 +406,12 @@ g_settings_real_writable_change_event (GSettings *settings, for (i = 0; i < n_keys; i++) { - const gchar *key = g_quark_to_string (keys[i]); + const gchar *key_name = g_quark_to_string (keys[i]); - if (g_str_has_suffix (key, "/")) + if (g_str_has_suffix (key_name, "/")) continue; - g_signal_emit (settings, g_settings_signals[SIGNAL_WRITABLE_CHANGED], keys[i], key); + g_signal_emit (settings, g_settings_signals[SIGNAL_WRITABLE_CHANGED], keys[i], key_name); } return FALSE; From f92002e9f59f43aa07af819e8b4ffeaa7124aba0 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:57:43 +0100 Subject: [PATCH 03/10] Fix non-initialized variable in gio/gresourcefile.c --- gio/gresourcefile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gio/gresourcefile.c b/gio/gresourcefile.c index 429e9ef49..35dffebe9 100644 --- a/gio/gresourcefile.c +++ b/gio/gresourcefile.c @@ -447,8 +447,8 @@ g_resource_file_query_info (GFile *file, GFileInfo *info; GFileAttributeMatcher *matcher; gboolean res; - gsize size; - guint32 resource_flags; + gsize size = 0; + guint32 resource_flags = 0; char **children; gboolean is_dir; char *base; From 2c734147cffc791ce1ec3aae8cf3c7c9eecd1342 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:57:29 +0100 Subject: [PATCH 04/10] Fix non-initialized variable in gio/gresource-tool.c --- gio/gresource-tool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gio/gresource-tool.c b/gio/gresource-tool.c index aa718974e..15c370155 100644 --- a/gio/gresource-tool.c +++ b/gio/gresource-tool.c @@ -477,8 +477,8 @@ static gint cmd_help (gboolean requested, const gchar *command) { - const gchar *description; - const gchar *synopsis; + const gchar *description = NULL; + const gchar *synopsis = NULL; gchar *option; GString *string; From 98c1b8461743f263bfe8f23e3ce6e1bc4faa8901 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:49:56 +0100 Subject: [PATCH 05/10] Fix redefinition of local variable and non-initialized variable in gio/gresource.c --- gio/gresource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gio/gresource.c b/gio/gresource.c index 53933f9d2..45ca92b1f 100644 --- a/gio/gresource.c +++ b/gio/gresource.c @@ -346,7 +346,7 @@ g_resource_find_overlay (const gchar *path, if (envvar != NULL) { gchar **parts; - gint i, j; + gint j; parts = g_strsplit (envvar, G_SEARCHPATH_SEPARATOR_S, 0); @@ -414,7 +414,7 @@ g_resource_find_overlay (const gchar *path, /* We go out of the way to avoid malloc() in the normal case * where the environment variable is not set. */ - static const gchar * const empty_strv[0 + 1]; + static const gchar *const empty_strv[0 + 1] = { 0 }; result = empty_strv; } From dd96eeee74e21d8bd96150d61bf90b46b6a7df83 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:49:05 +0100 Subject: [PATCH 06/10] Fix redefinition of local variable in gio/gregistrysettingsbackend.c --- gio/gregistrysettingsbackend.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gio/gregistrysettingsbackend.c b/gio/gregistrysettingsbackend.c index bae066a0a..a7171a21f 100644 --- a/gio/gregistrysettingsbackend.c +++ b/gio/gregistrysettingsbackend.c @@ -1200,7 +1200,7 @@ g_registry_backend_get_writable (GSettingsBackend *backend, GRegistryBackend *self = G_REGISTRY_BACKEND (backend); gchar *path_name; gunichar2 *path_namew; - gchar *value_name; + gchar *value_name = NULL; HKEY hpath; LONG result; @@ -1495,14 +1495,14 @@ registry_cache_update (GRegistryBackend *self, child_item->readable = TRUE; if (changed && event != NULL) { - gchar *item; + gchar *item_path; if (partial_key_name == NULL) - item = g_strdup (buffer); + item_path = g_strdup (buffer); else - item = g_build_path ("/", partial_key_name, buffer, NULL); + item_path = g_build_path ("/", partial_key_name, buffer, NULL); - g_ptr_array_add (event->items, item); + g_ptr_array_add (event->items, item_path); } g_free (buffer); From 124733d10c17c27223659f31eb0610e9de42c015 Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:47:38 +0100 Subject: [PATCH 07/10] Fix redefinition of local variable in gio/gnetworkservice.c --- gio/gnetworkservice.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gio/gnetworkservice.c b/gio/gnetworkservice.c index 2b8571e9b..f5ba9d848 100644 --- a/gio/gnetworkservice.c +++ b/gio/gnetworkservice.c @@ -445,7 +445,7 @@ g_network_service_address_enumerator_next (GSocketAddressEnumerator *enumerator { if (srv_enum->addr_enum == NULL && srv_enum->t) { - GError *error = NULL; + GError *my_error = NULL; gchar *uri; gchar *hostname; GSocketConnectable *addr; @@ -477,15 +477,15 @@ g_network_service_address_enumerator_next (GSocketAddressEnumerator *enumerator addr = g_network_address_parse_uri (uri, g_srv_target_get_port (target), - &error); + &my_error); g_free (uri); if (addr == NULL) { if (srv_enum->error == NULL) - srv_enum->error = error; + srv_enum->error = my_error; else - g_error_free (error); + g_error_free (my_error); continue; } @@ -498,18 +498,18 @@ g_network_service_address_enumerator_next (GSocketAddressEnumerator *enumerator if (srv_enum->addr_enum) { - GError *error = NULL; + GError *my_error = NULL; ret = g_socket_address_enumerator_next (srv_enum->addr_enum, cancellable, - &error); + &my_error); - if (error) + if (my_error) { if (srv_enum->error == NULL) - srv_enum->error = error; + srv_enum->error = my_error; else - g_error_free (error); + g_error_free (my_error); } if (!ret) From d0dfc765540eabf26d95fb4b05a450082cd53d9e Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 19:38:41 +0100 Subject: [PATCH 08/10] Fix redefinition of local variable and non-initialized variable in gio/glocalfileoutputstream.c --- gio/glocalfileoutputstream.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c index 71a992668..5d6a48840 100644 --- a/gio/glocalfileoutputstream.c +++ b/gio/glocalfileoutputstream.c @@ -855,7 +855,7 @@ handle_overwrite_open (const char *filename, int open_flags; int res; int mode; - int errsv; + int errsv = 0; gboolean replace_destination_set = (flags & G_FILE_CREATE_REPLACE_DESTINATION); mode = mode_from_flags_or_info (flags, reference_info); @@ -1179,7 +1179,7 @@ handle_overwrite_open (const char *filename, /* Seek back to the start of the file after the backup copy */ if (lseek (fd, 0, SEEK_SET) == -1) { - int errsv = errno; + errsv = errno; g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv), @@ -1195,7 +1195,7 @@ handle_overwrite_open (const char *filename, if (g_unlink (filename) != 0) { - int errsv = errno; + errsv = errno; g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv), @@ -1211,8 +1211,10 @@ handle_overwrite_open (const char *filename, fd = g_open (filename, open_flags, mode); if (fd == -1) { - int errsv = errno; - char *display_name = g_filename_display_name (filename); + char *display_name; + errsv = errno; + display_name = g_filename_display_name (filename); + g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv), _("Error opening file ā€œ%sā€: %s"), @@ -1230,7 +1232,7 @@ handle_overwrite_open (const char *filename, if (ftruncate (fd, 0) == -1) #endif { - int errsv = errno; + errsv = errno; g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv), From 9380a8cdb084c5c497a2ab9321cc5e20a0c2c39f Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:45:46 +0100 Subject: [PATCH 09/10] Fix redefinition of local variable in gio/glocalfilemonitor.c --- gio/glocalfilemonitor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c index 7e922561a..4f85fea52 100644 --- a/gio/glocalfilemonitor.c +++ b/gio/glocalfilemonitor.c @@ -406,7 +406,7 @@ g_file_monitor_source_handle_event (GFileMonitorSource *fms, g_assert (!other && rename_to); if (fms->flags & (G_FILE_MONITOR_WATCH_MOVES | G_FILE_MONITOR_SEND_MOVED)) { - GFile *other; + GFile *other_file; const gchar *dirname; gchar *allocated_dirname = NULL; GFileMonitorEvent event; @@ -421,11 +421,11 @@ g_file_monitor_source_handle_event (GFileMonitorSource *fms, dirname = allocated_dirname; } - other = g_local_file_new_from_dirname_and_basename (dirname, rename_to); + other_file = g_local_file_new_from_dirname_and_basename (dirname, rename_to); g_file_monitor_source_file_changes_done (fms, rename_to); - g_file_monitor_source_send_event (fms, event, child, other); + g_file_monitor_source_send_event (fms, event, child, other_file); - g_object_unref (other); + g_object_unref (other_file); g_free (allocated_dirname); } else From 7a5025934546b627368eb01f7888155a8567e3fb Mon Sep 17 00:00:00 2001 From: Loic Le Page Date: Wed, 19 Jan 2022 18:45:20 +0100 Subject: [PATCH 10/10] Fix redefinition of local variable in gio/glib-compile-schemas.c --- gio/glib-compile-schemas.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c index 7e1152f6b..83184e1e8 100644 --- a/gio/glib-compile-schemas.c +++ b/gio/glib-compile-schemas.c @@ -1038,7 +1038,7 @@ schema_state_add_override (SchemaState *state, GError **error) { SchemaState *parent; - KeyState *original; + KeyState *original = NULL; if (state->extends == NULL) { @@ -1386,14 +1386,14 @@ start_element (GMarkupParseContext *context, } else if (strcmp (element_name, "override") == 0) { - const gchar *name, *l10n, *context; + const gchar *name, *l10n, *str_context; - if (COLLECT (STRING, "name", &name, - OPTIONAL | STRING, "l10n", &l10n, - OPTIONAL | STRING, "context", &context)) + if (COLLECT (STRING, "name", &name, + OPTIONAL | STRING, "l10n", &l10n, + OPTIONAL | STRING, "context", &str_context)) schema_state_add_override (state->schema_state, &state->key_state, &state->string, - name, l10n, context, error); + name, l10n, str_context, error); return; } } @@ -1403,11 +1403,11 @@ start_element (GMarkupParseContext *context, { if (strcmp (element_name, "default") == 0) { - const gchar *l10n, *context; - if (COLLECT (STRING | OPTIONAL, "l10n", &l10n, - STRING | OPTIONAL, "context", &context)) + const gchar *l10n, *str_context; + if (COLLECT (STRING | OPTIONAL, "l10n", &l10n, + STRING | OPTIONAL, "context", &str_context)) state->string = key_state_start_default (state->key_state, - l10n, context, error); + l10n, str_context, error); return; }