Ticket #4179: mc-4179-chattr.c-fix-cast-qual-warning.patch

File mc-4179-chattr.c-fix-cast-qual-warning.patch, 1.8 KB (added by and, 3 years ago)
  • src/filemanager/chattr.c

    From 29fceb26aef5a65592dc62f1d17a68fa8312205d Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Tue, 22 Dec 2020 16:19:33 +0000
    Subject: [PATCH] (chattr.c) Fix -Wcast-qual warning
    
    chattr.c:398:34: warning: cast from 'const struct WChattrBoxes *' to 'struct WGroup *' drops const qualifier [-Wcast-qual]
        w = WIDGET (g_list_nth_data (GROUP (cb)->widgets, Id - cb->top));
                                     ^
    ../../lib/widget/group.h:16:29: note: expanded from macro 'GROUP'
    #define GROUP(x) ((WGroup *)(x))
                                ^
    chattr.c:515:27: warning: cast from 'const struct WChattrBoxes *' to 'struct WGroup *' drops const qualifier [-Wcast-qual]
        for (i = cb->top, l = GROUP (cb)->widgets; l != NULL; i++, l = g_list_next (l))
                              ^
    ../../lib/widget/group.h:16:29: note: expanded from macro 'GROUP'
    #define GROUP(x) ((WGroup *)(x))
                                ^
    
    Found by Clang-11
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/filemanager/chattr.c | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/src/filemanager/chattr.c b/src/filemanager/chattr.c
    index a8afaa33d..1b5121aa4 100644
    a b chattr_toggle_select (const WChattrBoxes * cb, int Id) 
    395395    Widget *w; 
    396396 
    397397    /* find checkbox */ 
    398     w = WIDGET (g_list_nth_data (GROUP (cb)->widgets, Id - cb->top)); 
     398    w = WIDGET (g_list_nth_data (CONST_GROUP (cb)->widgets, Id - cb->top)); 
    399399 
    400400    check_attr[Id].selected = !check_attr[Id].selected; 
    401401 
    checkboxes_save_state (const WChattrBoxes * cb) 
    512512    int i; 
    513513    GList *l; 
    514514 
    515     for (i = cb->top, l = GROUP (cb)->widgets; l != NULL; i++, l = g_list_next (l)) 
     515    for (i = cb->top, l = CONST_GROUP (cb)->widgets; l != NULL; i++, l = g_list_next (l)) 
    516516    { 
    517517        int m; 
    518518