Ticket #3547: mc-3547-cleanup-conversion-warning-menubar_selected.patch

File mc-3547-cleanup-conversion-warning-menubar_selected.patch, 4.2 KB (added by and, 8 years ago)
  • lib/widget/menu.h

    fix -Wconversion warning at WMenuBar selected value
    
    edit menubar key value use -1 as non-selected flag, shift logic to 0 as non-selected flag for edit menubar key
    
    patch will fix following warnings:
    menu.c:123:73: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'guint' (aka 'unsigned int') [-Wshorten-64-to-32]
    menu.c:181:73: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'guint' (aka 'unsigned int') [-Wshorten-64-to-32]
    menu.c:250:75: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'guint' (aka 'unsigned int') [-Wshorten-64-to-32]
    menu.c:332:73: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'guint' (aka 'unsigned int') [-Wshorten-64-to-32]
    menu.c:351:67: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'guint' (aka 'unsigned int') [-Wshorten-64-to-32]
    menu.c:372:67: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'guint' (aka 'unsigned int') [-Wshorten-64-to-32]
    menu.c:396:67: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'guint' (aka 'unsigned int') [-Wshorten-64-to-32]
    menu.c:425:67: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'guint' (aka 'unsigned int') [-Wshorten-64-to-32]
    menu.c:470:68: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'guint' (aka 'unsigned int') [-Wshorten-64-to-32]
    menu.c:511:45: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]
    menu.c:517:71: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'guint' (aka 'unsigned int') [-Wshorten-64-to-32]
    menu.c:721:59: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'guint' (aka 'unsigned int') [-Wshorten-64-to-32]
    editmenu.c:277:33: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
    
    patch against a5cd0093c5330ae6118cbf2830cf288dd4a68ed0
    compile test with gcc 4.6/4.9/5.2 and clang 3.7
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    
    a c  
    3434    gboolean is_active;         /* If the menubar is in use */ 
    3535    gboolean is_dropped;        /* If the menubar has dropped */ 
    3636    GList *menu;                /* The actual menus */ 
    37     size_t selected;            /* Selected menu on the top bar */ 
     37    guint selected;             /* Selected menu on the top bar */ 
    3838    unsigned long previous_widget;      /* Selected widget ID before activating menu */ 
    3939} WMenuBar; 
    4040 
  • src/editor/editmenu.c

    a c  
    263263/* --------------------------------------------------------------------------------------------- */ 
    264264 
    265265static void 
    266 edit_drop_menu_cmd (WDialog * h, int which) 
     266edit_drop_menu_cmd (WDialog * h, guint which) 
    267267{ 
    268268    WMenuBar *menubar; 
    269269 
     
    273273    { 
    274274        menubar->is_active = TRUE; 
    275275        menubar->is_dropped = (drop_menus != 0); 
    276         if (which >= 0) 
    277             menubar->selected = which; 
     276        if (which > 0) 
     277            menubar->selected = which - 1; 
    278278 
    279279        menubar->previous_widget = dlg_get_current_widget_id (h); 
    280280        dlg_select_widget (menubar); 
     
    312312void 
    313313edit_menu_cmd (WDialog * h) 
    314314{ 
    315     edit_drop_menu_cmd (h, -1); 
     315    edit_drop_menu_cmd (h, 0); 
    316316} 
    317317 
    318318/* --------------------------------------------------------------------------------------------- */ 
     
    320320gboolean 
    321321edit_drop_hotkey_menu (WDialog * h, int key) 
    322322{ 
    323     int m = 0; 
     323    guint m = 0; 
    324324    switch (key) 
    325325    { 
    326326    case ALT ('f'): 
    327         m = 0; 
     327        m = 1; 
    328328        break; 
    329329    case ALT ('e'): 
    330         m = 1; 
     330        m = 2; 
    331331        break; 
    332332    case ALT ('s'): 
    333         m = 2; 
     333        m = 3; 
    334334        break; 
    335335    case ALT ('c'): 
    336         m = 3; 
     336        m = 4; 
    337337        break; 
    338338    case ALT ('m'): 
    339         m = 4; 
     339        m = 5; 
    340340        break; 
    341341    case ALT ('w'): 
    342         m = 5; 
     342        m = 6; 
    343343        break; 
    344344    case ALT ('o'): 
    345         m = 6; 
     345        m = 7; 
    346346        break; 
    347347    default: 
    348348        return FALSE;