Blame 0059-utils-make-arguments-of-a-list-func-const.patch

3a204fb
From ecbc26cd7ceb416db501aab405adca75523bb97b Mon Sep 17 00:00:00 2001
3a204fb
From: Jakub Filak <jfilak@redhat.com>
3a204fb
Date: Thu, 29 Jan 2015 11:24:39 +0100
3a204fb
Subject: [PATCH] utils: make arguments of a list func const
3a204fb
3a204fb
Related to #316
3a204fb
3a204fb
Signed-off-by: Jakub Filak <jfilak@redhat.com>
3a204fb
---
3a204fb
 src/gtk-helpers/problem_details_widget.c | 6 +++---
3a204fb
 src/include/internal_libreport.h         | 4 ++--
3a204fb
 src/lib/is_in_string_list.c              | 4 ++--
3a204fb
 src/lib/make_descr.c                     | 6 +++---
3a204fb
 src/lib/problem_data.c                   | 8 ++++----
3a204fb
 5 files changed, 14 insertions(+), 14 deletions(-)
3a204fb
3a204fb
diff --git a/src/gtk-helpers/problem_details_widget.c b/src/gtk-helpers/problem_details_widget.c
3a204fb
index fed65b2..d8d78e9 100644
3a204fb
--- a/src/gtk-helpers/problem_details_widget.c
3a204fb
+++ b/src/gtk-helpers/problem_details_widget.c
3a204fb
@@ -232,7 +232,7 @@ static void
3a204fb
 problem_data_entry_to_grid_row_one_line(const char *item_name, problem_item *item, ProblemDetailsWidget *self)
3a204fb
 {
3a204fb
     if (((item->flags & CD_FLAG_TXT) && (strchr(item->content, '\n') == NULL))
3a204fb
-             && !is_in_string_list(item_name, (char **)items_auto_blacklist))
3a204fb
+             && !is_in_string_list(item_name, items_auto_blacklist))
3a204fb
         problem_details_widget_add_single_line(self, item_name, item->content);
3a204fb
 }
3a204fb
 
3a204fb
@@ -240,7 +240,7 @@ static void
3a204fb
 problem_data_entry_to_grid_row_multi_line(const char *item_name, problem_item *item, ProblemDetailsWidget *self)
3a204fb
 {
3a204fb
     if (((item->flags & CD_FLAG_TXT) && (strchr(item->content, '\n') != NULL))
3a204fb
-            && !is_in_string_list(item_name, (char **)items_auto_blacklist))
3a204fb
+            && !is_in_string_list(item_name, items_auto_blacklist))
3a204fb
         problem_details_widget_add_multi_line(self, item_name, item->content);
3a204fb
 }
3a204fb
 
3a204fb
@@ -248,7 +248,7 @@ static void
3a204fb
 problem_data_entry_to_grid_row_binary(const char *item_name, problem_item *item, ProblemDetailsWidget *self)
3a204fb
 {
3a204fb
     if ((item->flags & CD_FLAG_BIN)
3a204fb
-            && !is_in_string_list(item_name, (char **)items_auto_blacklist))
3a204fb
+            && !is_in_string_list(item_name, items_auto_blacklist))
3a204fb
         problem_details_widget_add_binary(self, item_name, item->content);
3a204fb
 }
3a204fb
 
3a204fb
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
3a204fb
index 00ff7a1..72ff240 100644
3a204fb
--- a/src/include/internal_libreport.h
3a204fb
+++ b/src/include/internal_libreport.h
3a204fb
@@ -294,10 +294,10 @@ char *run_in_shell_and_save_output(int flags,
3a204fb
 /* Random utility functions */
3a204fb
 
3a204fb
 #define is_in_string_list libreport_is_in_string_list
3a204fb
-bool is_in_string_list(const char *name, char **v);
3a204fb
+bool is_in_string_list(const char *name, const char *const *v);
3a204fb
 
3a204fb
 #define index_of_string_in_list libreport_index_of_string_in_list
3a204fb
-int index_of_string_in_list(const char *name, char **v);
3a204fb
+int index_of_string_in_list(const char *name, const char *const *v);
3a204fb
 
3a204fb
 #define is_in_comma_separated_list libreport_is_in_comma_separated_list
3a204fb
 bool is_in_comma_separated_list(const char *value, const char *list);
3a204fb
diff --git a/src/lib/is_in_string_list.c b/src/lib/is_in_string_list.c
3a204fb
index e0ee26b..b75abe4 100644
3a204fb
--- a/src/lib/is_in_string_list.c
3a204fb
+++ b/src/lib/is_in_string_list.c
3a204fb
@@ -18,7 +18,7 @@
3a204fb
 */
3a204fb
 #include "internal_libreport.h"
3a204fb
 
3a204fb
-bool is_in_string_list(const char *name, char **v)
3a204fb
+bool is_in_string_list(const char *name, const char *const *v)
3a204fb
 {
3a204fb
     while (*v)
3a204fb
     {
3a204fb
@@ -29,7 +29,7 @@ bool is_in_string_list(const char *name, char **v)
3a204fb
     return false;
3a204fb
 }
3a204fb
 
3a204fb
-int index_of_string_in_list(const char *name, char **v)
3a204fb
+int index_of_string_in_list(const char *name, const char *const *v)
3a204fb
 {
3a204fb
     for(int i = 0; v[i]; ++i)
3a204fb
     {
3a204fb
diff --git a/src/lib/make_descr.c b/src/lib/make_descr.c
3a204fb
index 2bcbebd..912b87f 100644
3a204fb
--- a/src/lib/make_descr.c
3a204fb
+++ b/src/lib/make_descr.c
3a204fb
@@ -20,7 +20,7 @@
3a204fb
 
3a204fb
 static bool rejected_name(const char *name, char **v, int flags)
3a204fb
 {
3a204fb
-    bool r = is_in_string_list(name, v);
3a204fb
+    bool r = is_in_string_list(name, (const char *const *)v);
3a204fb
     if (flags & MAKEDESC_WHITELIST)
3a204fb
          r = !r;
3a204fb
     return r;
3a204fb
@@ -59,8 +59,8 @@ static int list_cmp(const char *s1, const char *s2)
3a204fb
             FILENAME_COUNT     ,
3a204fb
             NULL
3a204fb
     };
3a204fb
-    int s1_index = index_of_string_in_list(s1, (char**) list_order);
3a204fb
-    int s2_index = index_of_string_in_list(s2, (char**) list_order);
3a204fb
+    int s1_index = index_of_string_in_list(s1, list_order);
3a204fb
+    int s2_index = index_of_string_in_list(s2, list_order);
3a204fb
 
3a204fb
     if(s1_index < 0 && s2_index < 0)
3a204fb
         return strcmp(s1, s2);
3a204fb
diff --git a/src/lib/problem_data.c b/src/lib/problem_data.c
3a204fb
index c57e57f..6b8bb01 100644
3a204fb
--- a/src/lib/problem_data.c
3a204fb
+++ b/src/lib/problem_data.c
3a204fb
@@ -267,7 +267,7 @@ static const char *const editable_files[] = {
3a204fb
 };
3a204fb
 static bool is_editable_file(const char *file_name)
3a204fb
 {
3a204fb
-    return is_in_string_list(file_name, (char**)editable_files);
3a204fb
+    return is_in_string_list(file_name, editable_files);
3a204fb
 }
3a204fb
 
3a204fb
 /* When is_text_file() returns this special pointer value,
3a204fb
@@ -317,7 +317,7 @@ static char* is_text_file(const char *name, ssize_t *sz)
3a204fb
     if (base)
3a204fb
     {
3a204fb
         base++;
3a204fb
-        if (is_in_string_list(base, (char**)always_text_files))
3a204fb
+        if (is_in_string_list(base, always_text_files))
3a204fb
             goto text;
3a204fb
     }
3a204fb
 
3a204fb
@@ -387,7 +387,7 @@ void problem_data_load_from_dump_dir(problem_data_t *problem_data, struct dump_d
3a204fb
     dd_init_next_file(dd);
3a204fb
     while (dd_get_next_file(dd, &short_name, &full_name))
3a204fb
     {
3a204fb
-        if (excluding && is_in_string_list(short_name, excluding))
3a204fb
+        if (excluding && is_in_string_list(short_name, (const char *const *)excluding))
3a204fb
         {
3a204fb
             //log("Excluded:'%s'", short_name);
3a204fb
             goto next;
3a204fb
@@ -458,7 +458,7 @@ void problem_data_load_from_dump_dir(problem_data_t *problem_data, struct dump_d
3a204fb
             FILENAME_REASON    ,
3a204fb
             NULL
3a204fb
         };
3a204fb
-        if (is_in_string_list(short_name, (char**)list_files))
3a204fb
+        if (is_in_string_list(short_name, list_files))
3a204fb
             flags |= CD_FLAG_LIST;
3a204fb
 
3a204fb
         if (strcmp(short_name, FILENAME_TIME) == 0)
3a204fb
-- 
3a204fb
2.1.0
3a204fb