Ticket #3598: mc-3598-0002-filemanager-panel.c-cleanup-Wcast-qual-warning.patch

File mc-3598-0002-filemanager-panel.c-cleanup-Wcast-qual-warning.patch, 8.6 KB (added by and, 8 years ago)
  • src/filemanager/panel.c

    From 6ce4601cef72a630f7b53c98c5b0683ccc509986 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sat, 20 Feb 2016 14:18:26 +0000
    Subject: [PATCH] filemanager/panel.c: cleanup -Wcast-qual warning
    
    In file included from ../../lib/widget.h:18:0,
                     from panel.c:53:
    panel.c: In function 'panel_lines':
    ../../lib/widget/widget-common.h:13:20: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     #define WIDGET(x) ((Widget *)(x))
                        ^
    panel.c:409:13: note: in expansion of macro 'WIDGET'
         return (WIDGET (p)->lines - 3 - (panels_options.show_mini_info ? 2 : 0));
                 ^
    panel.c: In function 'display_total_marked_size':
    ../../lib/widget/widget-common.h:13:20: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     #define WIDGET(x) ((Widget *)(x))
                        ^
    panel.c:1070:17: note: in expansion of macro 'WIDGET'
         Widget *w = WIDGET (panel);
                     ^
    panel.c:1094:11: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
         buf = (char *) str_trunc (buf, cols - 4);
               ^
    In file included from ../../lib/widget.h:18:0,
                     from panel.c:53:
    panel.c: In function 'mini_info_separator':
    ../../lib/widget/widget-common.h:13:20: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     #define WIDGET(x) ((Widget *)(x))
                        ^
    panel.c:1116:21: note: in expansion of macro 'WIDGET'
             Widget *w = WIDGET (panel);
                         ^
    panel.c: In function 'show_free_space':
    ../../lib/widget/widget-common.h:13:20: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     #define WIDGET(x) ((Widget *)(x))
                        ^
    panel.c:1159:21: note: in expansion of macro 'WIDGET'
             Widget *w = WIDGET (panel);
                         ^
    panel.c: In function 'show_dir':
    ../../lib/widget/widget-common.h:13:20: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     #define WIDGET(x) ((Widget *)(x))
                        ^
    panel.c:1260:17: note: in expansion of macro 'WIDGET'
         Widget *w = WIDGET (panel);
                     ^
    panel.c: In function 'panel_paint_sort_info':
    ../../lib/widget/widget-common.h:13:20: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     #define WIDGET(x) ((Widget *)(x))
                        ^
    ../../lib/widget/widget-common.h:15:44: note: in expansion of macro 'WIDGET'
     #define widget_move(w, _y, _x) tty_gotoyx (WIDGET(w)->y + (_y), WIDGET(w)->x + (_x))
                                                ^
    panel.c:1524:9: note: in expansion of macro 'widget_move'
             widget_move (panel, 1, 1);
             ^
    ../../lib/widget/widget-common.h:13:20: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     #define WIDGET(x) ((Widget *)(x))
                        ^
    ../../lib/widget/widget-common.h:15:65: note: in expansion of macro 'WIDGET'
     #define widget_move(w, _y, _x) tty_gotoyx (WIDGET(w)->y + (_y), WIDGET(w)->x + (_x))
                                                                     ^
    panel.c:1524:9: note: in expansion of macro 'widget_move'
             widget_move (panel, 1, 1);
             ^
    panel.c: In function 'panel_print_header':
    ../../lib/widget/widget-common.h:13:20: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
     #define WIDGET(x) ((Widget *)(x))
                        ^
    panel.c:1558:17: note: in expansion of macro 'WIDGET'
         Widget *w = WIDGET (panel);
                     ^
    panel.c: In function 'panel_get_sortable_fields':
    panel.c:4879:12: warning: to be safe all intermediate pointers in cast from 'char **' to 'const char **' must be 'const' qualified [-Wcast-qual]
         return (const char **) ret;
                ^
    panel.c: In function 'panel_get_user_possible_fields':
    panel.c:4967:12: warning: to be safe all intermediate pointers in cast from 'char **' to 'const char **' must be 'const' qualified [-Wcast-qual]
         return (const char **) ret;
                ^
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/filemanager/panel.c | 25 +++++++++++++------------
     src/filemanager/panel.h |  4 ++--
     2 files changed, 15 insertions(+), 14 deletions(-)
    
    diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c
    index 1fce969..1509b73 100644
    a b static int 
    406406panel_lines (const WPanel * p) 
    407407{ 
    408408    /* 3 lines are: top frame, column header, botton frame */ 
    409     return (WIDGET (p)->lines - 3 - (panels_options.show_mini_info ? 2 : 0)); 
     409    return (CWIDGET (p)->lines - 3 - (panels_options.show_mini_info ? 2 : 0)); 
    410410} 
    411411 
    412412/* --------------------------------------------------------------------------------------------- */ 
    paint_dir (WPanel * panel) 
    10671067static void 
    10681068display_total_marked_size (const WPanel * panel, int y, int x, gboolean size_only) 
    10691069{ 
    1070     Widget *w = WIDGET (panel); 
     1070    const Widget *w = CWIDGET (panel); 
    10711071 
    1072     char buffer[BUF_SMALL], b_bytes[BUF_SMALL], *buf; 
     1072    char buffer[BUF_SMALL], b_bytes[BUF_SMALL]; 
     1073    const char *buf; 
    10731074    int cols; 
    10741075 
    10751076    if (panel->marked <= 0) 
    display_total_marked_size (const WPanel * panel, int y, int x, gboolean size_onl 
    10911092                    b_bytes, panel->marked); 
    10921093 
    10931094    /* don't forget spaces around buffer content */ 
    1094     buf = (char *) str_trunc (buf, cols - 4); 
     1095    buf = str_trunc (buf, cols - 4); 
    10951096 
    10961097    if (x < 0) 
    10971098        /* center in panel */ 
    mini_info_separator (const WPanel * panel) 
    11131114{ 
    11141115    if (panels_options.show_mini_info) 
    11151116    { 
    1116         Widget *w = WIDGET (panel); 
     1117        const Widget *w = CWIDGET (panel); 
    11171118        int y; 
    11181119 
    11191120        y = panel_lines (panel) + 2; 
    show_free_space (const WPanel * panel) 
    11561157 
    11571158    if (myfs_stats.avail != 0 || myfs_stats.total != 0) 
    11581159    { 
    1159         Widget *w = WIDGET (panel); 
     1160        const Widget *w = CWIDGET (panel); 
    11601161        char buffer1[6], buffer2[6], tmp[BUF_SMALL]; 
    11611162 
    11621163        size_trunc_len (buffer1, sizeof (buffer1) - 1, myfs_stats.avail, 1, 
    panel_get_encoding_info_str (const WPanel * panel) 
    12571258static void 
    12581259show_dir (const WPanel * panel) 
    12591260{ 
    1260     Widget *w = WIDGET (panel); 
     1261    const Widget *w = CWIDGET (panel); 
    12611262 
    12621263    gchar *tmp; 
    12631264 
    panel_get_title_without_hotkey (const char *title) 
    15551556static void 
    15561557panel_print_header (const WPanel * panel) 
    15571558{ 
    1558     Widget *w = WIDGET (panel); 
     1559    const Widget *w = CWIDGET (panel); 
    15591560 
    15601561    int y, x; 
    15611562    int i; 
    panel_get_num_of_sortable_fields (void) 
    48554856 
    48564857/* --------------------------------------------------------------------------------------------- */ 
    48574858 
    4858 const char ** 
     4859char ** 
    48594860panel_get_sortable_fields (gsize * array_size) 
    48604861{ 
    48614862    char **ret; 
    panel_get_sortable_fields (gsize * array_size) 
    48764877        if (panel_fields[i].is_user_choice) 
    48774878            ret[lc_index++] = g_strdup (_(panel_fields[i].title_hotkey)); 
    48784879 
    4879     return (const char **) ret; 
     4880    return ret; 
    48804881} 
    48814882 
    48824883/* --------------------------------------------------------------------------------------------- */ 
    panel_get_num_of_user_possible_fields (void) 
    49434944 
    49444945/* --------------------------------------------------------------------------------------------- */ 
    49454946 
    4946 const char ** 
     4947char ** 
    49474948panel_get_user_possible_fields (gsize * array_size) 
    49484949{ 
    49494950    char **ret; 
    panel_get_user_possible_fields (gsize * array_size) 
    49644965        if (panel_fields[i].use_in_user_format) 
    49654966            ret[lc_index++] = g_strdup (_(panel_fields[i].title_hotkey)); 
    49664967 
    4967     return (const char **) ret; 
     4968    return ret; 
    49684969} 
    49694970 
    49704971/* --------------------------------------------------------------------------------------------- */ 
  • src/filemanager/panel.h

    diff --git a/src/filemanager/panel.h b/src/filemanager/panel.h
    index 4f3cd0d..d3f792e 100644
    a b void do_file_mark (WPanel * panel, int idx, int val); 
    180180gboolean do_panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_type); 
    181181 
    182182gsize panel_get_num_of_sortable_fields (void); 
    183 const char **panel_get_sortable_fields (gsize *); 
     183char **panel_get_sortable_fields (gsize *); 
    184184const panel_field_t *panel_get_field_by_id (const char *); 
    185185const panel_field_t *panel_get_field_by_title (const char *); 
    186186const panel_field_t *panel_get_field_by_title_hotkey (const char *); 
    187187gsize panel_get_num_of_user_possible_fields (void); 
    188 const char **panel_get_user_possible_fields (gsize *); 
     188char **panel_get_user_possible_fields (gsize *); 
    189189void panel_set_cwd (WPanel * panel, const vfs_path_t * vpath); 
    190190void panel_set_lwd (WPanel * panel, const vfs_path_t * vpath); 
    191191