[gnome-autoar/wip/oholy/initialize-gauto] Add missing initialization for g_auto* variables
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-autoar/wip/oholy/initialize-gauto] Add missing initialization for g_auto* variables
- Date: Tue, 7 Dec 2021 11:59:21 +0000 (UTC)
commit 97c3317773c270557b770bcdb60cf6c2826f7544
Author: Ondrej Holy <oholy redhat com>
Date: Tue Dec 7 12:28:57 2021 +0100
Add missing initialization for g_auto* variables
When building Fedora package, I see many "may be used uninitialzed"
warnings. I am not sure why but I don't see those warnings locally even
when `-Wmaybe-uninitialized` is used. Anyway, this is because the
`g_autofree` and `g_autoptr` variables are not explicitely initialized
as mentioned in the documentation. Let's initialize them to get rid of
those warnings.
gnome-autoar/autoar-compressor.c | 4 ++--
gnome-autoar/autoar-extractor.c | 18 +++++++++---------
tests/test-extract-unit.c | 8 ++++----
tests/test-extract.c | 2 +-
4 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/gnome-autoar/autoar-compressor.c b/gnome-autoar/autoar-compressor.c
index 5fd32b2..9d52213 100644
--- a/gnome-autoar/autoar-compressor.c
+++ b/gnome-autoar/autoar-compressor.c
@@ -1521,7 +1521,7 @@ autoar_compressor_step_create (AutoarCompressor *self)
GFile *file; /* Do not unref */
GFileType filetype;
GFileInfo *fileinfo;
- g_autofree gchar *pathname;
+ g_autofree gchar *pathname = NULL;
file = l->data;
@@ -1583,7 +1583,7 @@ autoar_compressor_step_cleanup (AutoarCompressor *self)
self->notify_last = 0;
autoar_compressor_signal_progress (self);
if (archive_write_close (self->a) != ARCHIVE_OK) {
- g_autofree gchar *output_name;
+ g_autofree gchar *output_name = NULL;
output_name = autoar_common_g_file_get_name (self->output_file);
diff --git a/gnome-autoar/autoar-extractor.c b/gnome-autoar/autoar-extractor.c
index ab68c47..7b8e049 100644
--- a/gnome-autoar/autoar-extractor.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -791,8 +791,8 @@ autoar_extractor_signal_conflict (AutoarExtractor *self,
return AUTOAR_CONFLICT_SKIP;
if (*new_file) {
- g_autofree char *previous_path;
- g_autofree char *new_path;
+ g_autofree char *previous_path = NULL;
+ g_autofree char *new_path = NULL;
previous_path = g_file_get_path (file);
new_path = g_file_get_path (*new_file);
@@ -886,8 +886,8 @@ autoar_extractor_do_sanitize_pathname (AutoarExtractor *self,
{
GFile *extracted_filename;
gboolean valid_filename;
- g_autofree char *sanitized_pathname;
- g_autofree char *utf8_pathname;
+ g_autofree char *sanitized_pathname = NULL;
+ g_autofree char *utf8_pathname = NULL;
GFile *destination;
/* Use output_file when called from autoar_extractor_step_scan_toplevel(). */
@@ -906,7 +906,7 @@ autoar_extractor_do_sanitize_pathname (AutoarExtractor *self,
g_file_has_prefix (extracted_filename, destination);
if (!valid_filename) {
- g_autofree char *basename;
+ g_autofree char *basename = NULL;
basename = g_file_get_basename (extracted_filename);
@@ -917,7 +917,7 @@ autoar_extractor_do_sanitize_pathname (AutoarExtractor *self,
if (self->prefix != NULL && self->new_prefix != NULL &&
!g_file_equal (self->prefix, self->new_prefix)) {
- g_autofree char *relative_path;
+ g_autofree char *relative_path = NULL;
/* Replace the old prefix with the new one */
relative_path = g_file_get_relative_path (self->prefix,
extracted_filename);
@@ -1780,8 +1780,8 @@ autoar_extractor_step_set_destination (AutoarExtractor *self)
* the extension). If they do, then the destination should be the output
* directory itself.
*/
- g_autofree char *prefix_name;
- g_autofree char *prefix_name_no_ext;
+ g_autofree char *prefix_name = NULL;
+ g_autofree char *prefix_name_no_ext = NULL;
g_debug ("autoar_extractor_step_set_destination: pathname_prefix = %s",
g_file_peek_path (self->prefix));
@@ -1813,7 +1813,7 @@ autoar_extractor_step_decide_destination (AutoarExtractor *self)
GList *files = NULL;
GList *l;
GFile *new_destination = NULL;
- g_autofree char *destination_name;
+ g_autofree char *destination_name = NULL;
for (l = self->files_list; l != NULL; l = l->next) {
char *relative_path;
diff --git a/tests/test-extract-unit.c b/tests/test-extract-unit.c
index 2662a5b..ba14f71 100644
--- a/tests/test-extract-unit.c
+++ b/tests/test-extract-unit.c
@@ -64,7 +64,7 @@ remove_directory (GFile *directory)
GFileInfo *info;
while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL) {
- g_autoptr (GFile) child;
+ g_autoptr (GFile) child = NULL;
child = g_file_get_child (directory, g_file_info_get_name (info));
@@ -334,8 +334,8 @@ scan_directory (GFile *directory,
NULL, NULL));
while (!g_queue_is_empty (files)) {
- g_autoptr (GFile) file;
- g_autoptr (GFileInfo) file_info;
+ g_autoptr (GFile) file = NULL;
+ g_autoptr (GFileInfo) file_info = NULL;
file = g_queue_pop_tail (files);
file_info = g_queue_pop_tail (file_infos);
@@ -398,7 +398,7 @@ reference_file_scanned (GFile *scanned_file,
gpointer user_data)
{
ExtractTest *extract_test = user_data;
- g_autofree char *relative_path;
+ g_autofree char *relative_path = NULL;
GFileInfo *corresponding_file_info;
relative_path = scanned_file == extract_test->reference ?
diff --git a/tests/test-extract.c b/tests/test-extract.c
index 6e84045..1077ae3 100644
--- a/tests/test-extract.c
+++ b/tests/test-extract.c
@@ -59,7 +59,7 @@ my_handler_conflict (AutoarExtractor *extractor,
GFile **new_file,
gpointer data)
{
- g_autofree char *path;
+ g_autofree char *path = NULL;
path = g_file_get_path (file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]