Ticket #3598: mc-3598-0017-filemanager-find.c-cleanup-Wcast-qual-warning.patch

File mc-3598-0017-filemanager-find.c-cleanup-Wcast-qual-warning.patch, 4.8 KB (added by and, 9 years ago)
  • src/filemanager/find.c

    From 864c802da99c33658e86c8c3659dcaa6eb2708d5 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sat, 20 Feb 2016 15:23:57 +0000
    Subject: [PATCH] filemanager/find.c: cleanup -Wcast-qual warning
    
    find.c:775:75: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
                 *start_dir = in_start->buffer[0] != '\0' ? in_start->buffer : (char *) ".";
                                                                               ^
    find.c: In function 'push_directory':
    find.c:829:36: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
         g_queue_push_head (&dir_queue, (void *) dir);
                                        ^
    find.c: In function 'find_rotate_dash':
    ../../lib/widget/widget-common.h:13:20: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     #define WIDGET(x) ((Widget *)(x))
                        ^
    find.c:1202:23: note: in expansion of macro 'WIDGET'
         const Widget *w = WIDGET (h);
                           ^
    find.c: In function 'find_calc_button_locations':
    ../../lib/widget/widget-common.h:13:20: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     #define WIDGET(x) ((Widget *)(x))
                        ^
    find.c:1432:22: note: in expansion of macro 'WIDGET'
         const int cols = WIDGET (h)->cols;
                          ^
    find.c: In function 'find_relocate_buttons':
    ../../lib/widget/widget-common.h:13:20: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     #define WIDGET(x) ((Widget *)(x))
                        ^
    find.c:1463:30: note: in expansion of macro 'WIDGET'
             fbuts[i].button->x = WIDGET (h)->x + fbuts[i].x;
                                  ^
    find.c: In function 'do_find':
    find.c:1679:20: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
         find_pattern = (char *) pattern;
                        ^
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/filemanager/find.c | 16 ++++++++--------
     1 file changed, 8 insertions(+), 8 deletions(-)
    
    diff --git a/src/filemanager/find.c b/src/filemanager/find.c
    index e0956d0..4a3eccf 100644
    a b find_parameters (char **start_dir, ssize_t * start_dir_len, 
    772772 
    773773            *content = (options.content_use && in_with->buffer[0] != '\0') 
    774774                ? g_strdup (in_with->buffer) : NULL; 
    775             *start_dir = in_start->buffer[0] != '\0' ? in_start->buffer : (char *) "."; 
     775            *start_dir = in_start->buffer[0] != '\0' ? g_strdup (in_start->buffer) : g_strdup ("."); 
    776776            *pattern = g_strdup (in_name->buffer); 
    777777            if (in_start_dir != INPUT_LAST_TEXT) 
    778778                g_free (in_start_dir); 
    779             in_start_dir = g_strdup (*start_dir); 
     779            in_start_dir = *start_dir; 
    780780 
    781781            s = tilde_expand (*start_dir); 
    782782            canonicalize_pathname (s); 
    find_parameters (char **start_dir, ssize_t * start_dir_len, 
    824824/* --------------------------------------------------------------------------------------------- */ 
    825825 
    826826static inline void 
    827 push_directory (const vfs_path_t * dir) 
     827push_directory (vfs_path_t * dir) 
    828828{ 
    829829    g_queue_push_head (&dir_queue, (void *) dir); 
    830830} 
    find_rotate_dash (const WDialog * h, gboolean show) 
    11991199{ 
    12001200    static size_t pos = 0; 
    12011201    static const char rotating_dash[4] = "|/-\\"; 
    1202     const Widget *w = WIDGET (h); 
     1202    const Widget *w = CWIDGET (h); 
    12031203 
    12041204    if (!verbose) 
    12051205        return; 
    view_edit_currently_selected_file (gboolean unparsed_view, gboolean edit) 
    14291429static void 
    14301430find_calc_button_locations (const WDialog * h, gboolean all_buttons) 
    14311431{ 
    1432     const int cols = WIDGET (h)->cols; 
     1432    const int cols = CWIDGET (h)->cols; 
    14331433 
    14341434    int l1, l2; 
    14351435 
    find_relocate_buttons (const WDialog * h, gboolean all_buttons) 
    14601460    find_calc_button_locations (h, all_buttons); 
    14611461 
    14621462    for (i = 0; i < fbuts_num; i++) 
    1463         fbuts[i].button->x = WIDGET (h)->x + fbuts[i].x; 
     1463        fbuts[i].button->x = CWIDGET (h)->x + fbuts[i].x; 
    14641464} 
    14651465 
    14661466/* --------------------------------------------------------------------------------------------- */ 
    do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, 
    16751675 
    16761676    setup_gui (); 
    16771677 
    1678     /* FIXME: Need to cleanup this, this ought to be passed non-globaly */ 
    1679     find_pattern = (char *) pattern; 
     1678    find_pattern = g_strdup (pattern); 
    16801679 
    16811680    content_pattern = NULL; 
    16821681    if (options.content_use && content != NULL && str_is_valid_string (content)) 
    do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, 
    17901789        } 
    17911790    } 
    17921791 
     1792    g_free (find_pattern); 
    17931793    g_free (content_pattern); 
    17941794    kill_gui (); 
    17951795    do_search (NULL);           /* force do_search to release resources */