[nautilus/wip/oholy/search-engine-fixes: 3/5] nautilus-search-engine: Explicitely initialize variables




commit 774175eac2c7da8903fe7ac8d7102a69fb857630
Author: Ondrej Holy <oholy redhat com>
Date:   Tue Feb 15 10:04:17 2022 +0100

    nautilus-search-engine: Explicitely initialize variables
    
    Currently, build warning is shown about the potential usage of
    uninitalized variable. This is false-positive, but let's explicitly
    initialize the variables to get rid of the warning.
    
    Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2152

 src/nautilus-search-engine-model.c  | 4 ++--
 src/nautilus-search-engine-recent.c | 2 +-
 src/nautilus-search-engine-simple.c | 5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/nautilus-search-engine-model.c b/src/nautilus-search-engine-model.c
index 8bf7da941..2c246edb3 100644
--- a/src/nautilus-search-engine-model.c
+++ b/src/nautilus-search-engine-model.c
@@ -171,7 +171,7 @@ model_directory_ready_cb (NautilusDirectory *directory,
         if (found && date_range != NULL)
         {
             NautilusQuerySearchType type;
-            guint64 current_file_unix_time;
+            guint64 current_file_unix_time = 0;
 
             type = nautilus_query_get_search_type (model->query);
             initial_date = g_ptr_array_index (date_range, 0);
@@ -185,7 +185,7 @@ model_directory_ready_cb (NautilusDirectory *directory,
             {
                 current_file_unix_time = nautilus_file_get_mtime (file);
             }
-            else
+            else if (type == NAUTILUS_QUERY_SEARCH_TYPE_CREATED)
             {
                 current_file_unix_time = nautilus_file_get_btime (file);
             }
diff --git a/src/nautilus-search-engine-recent.c b/src/nautilus-search-engine-recent.c
index 106fc6abf..7195c8a87 100644
--- a/src/nautilus-search-engine-recent.c
+++ b/src/nautilus-search-engine-recent.c
@@ -294,7 +294,7 @@ recent_thread_func (gpointer user_data)
             if (date_range != NULL)
             {
                 NautilusQuerySearchType type;
-                guint64 target_time;
+                guint64 target_time = 0;
                 GDateTime *initial_date;
                 GDateTime *end_date;
 
diff --git a/src/nautilus-search-engine-simple.c b/src/nautilus-search-engine-simple.c
index 3ed02e016..2d89e42f4 100644
--- a/src/nautilus-search-engine-simple.c
+++ b/src/nautilus-search-engine-simple.c
@@ -360,7 +360,7 @@ visit_directory (GFile            *dir,
 
         if (found && date_range != NULL)
         {
-            guint64 current_file_time;
+            guint64 current_file_time = 0;
 
             initial_date = g_ptr_array_index (date_range, 0);
             end_date = g_ptr_array_index (date_range, 1);
@@ -373,10 +373,11 @@ visit_directory (GFile            *dir,
             {
                 current_file_time = mtime;
             }
-            else
+            else if (type == NAUTILUS_QUERY_SEARCH_TYPE_CREATED)
             {
                 current_file_time = ctime;
             }
+
             found = nautilus_file_date_in_between (current_file_time,
                                                    initial_date,
                                                    end_date);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]