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

File mc-3547-cleanup-conversion-warning-keybind_t.patch, 18.8 KB (added by and, 8 years ago)
  • lib/keybind.c

    fix -Wconversion warning at *_keymap_t and follow ups
    
    CK_InsertChar defined as a negative number so use int and not unsigned long
    command and action field convert to int also as follow up
    
    patch will resolve following warnings:
    buttonbar.c:153:68: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    dialog.c:351:44: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    input.c:1093:39: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    listbox.c:444:40: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    menu.c:341:55: warning: implicit conversion loses integer precision: 'const unsigned long' to 'int' [-Wshorten-64-to-32]
    keybind.c:49:20: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    lock.c:184:11: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
    midnight.c:1322:70: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    midnight.c:1570:48: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    midnight.c:1573:50: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    midnight.c:1579:50: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    panel.c:3674:42: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    tree.c:1241:40: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    actions_cmd.c:681:39: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    actions_cmd.c:729:46: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    actions_cmd.c:737:46: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    edit.c:1673:30: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    edit.c:3912:47: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    editcmd.c:1870:15: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    editcmd.c:2032:57: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    editcmd.c:3404:37: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    editwidget.c:926:19: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    editwidget.c:1025:52: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    editwidget.c:1030:49: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    editwidget.c:1041:52: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    editwidget.c:1136:46: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    editwidget.c:1146:38: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    ydiff.c:3359:39: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    ydiff.c:3410:45: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    ydiff.c:3418:46: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    help.c:971:38: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    help.c:977:38: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    setup.c:701:61: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    setup.c:695:22: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    
    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 b  
    395395/* --------------------------------------------------------------------------------------------- */ 
    396396 
    397397static void 
    398 keymap_add (GArray * keymap, long key, unsigned long cmd, const char *caption) 
     398keymap_add (GArray * keymap, long key, int cmd, const char *caption) 
    399399{ 
    400400    if (key != 0 && cmd != CK_IgnoreKey) 
    401401    { 
     
    413413/* --------------------------------------------------------------------------------------------- */ 
    414414 
    415415void 
    416 keybind_cmd_bind (GArray * keymap, const char *keybind, unsigned long action) 
     416keybind_cmd_bind (GArray * keymap, const char *keybind, int action) 
    417417{ 
    418418    char *caption = NULL; 
    419419    long key; 
     
    425425 
    426426/* --------------------------------------------------------------------------------------------- */ 
    427427 
    428 unsigned long 
     428int 
    429429keybind_lookup_action (const char *name) 
    430430{ 
    431431    const name_keymap_t key = { name, 0 }; 
     
    442442/* --------------------------------------------------------------------------------------------- */ 
    443443 
    444444const char * 
    445 keybind_lookup_actionname (unsigned long action) 
     445keybind_lookup_actionname (int action) 
    446446{ 
    447447    size_t i; 
    448448 
     
    456456/* --------------------------------------------------------------------------------------------- */ 
    457457 
    458458const char * 
    459 keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, unsigned long action) 
     459keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, int action) 
    460460{ 
    461461    if (keymap != NULL) 
    462462    { 
     
    471471 
    472472/* --------------------------------------------------------------------------------------------- */ 
    473473 
    474 unsigned long 
     474int 
    475475keybind_lookup_keymap_command (const global_keymap_t * keymap, long key) 
    476476{ 
    477477    if (keymap != NULL) 
  • lib/keybind.h

    a b  
    339339typedef struct name_keymap_t 
    340340{ 
    341341    const char *name; 
    342     unsigned long val; 
     342    int val; 
    343343} name_keymap_t; 
    344344 
    345345typedef struct key_config_t 
     
    354354typedef struct global_keymap_t 
    355355{ 
    356356    long key; 
    357     unsigned long command; 
     357    int command; 
    358358    char caption[KEYMAP_SHORTCUT_LENGTH]; 
    359359} global_keymap_t; 
    360360 
     
    362362 
    363363/*** declarations of public functions ************************************************************/ 
    364364 
    365 void keybind_cmd_bind (GArray * keymap, const char *keybind, unsigned long action); 
    366 unsigned long keybind_lookup_action (const char *name); 
    367 const char *keybind_lookup_actionname (unsigned long action); 
    368 const char *keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, unsigned long action); 
    369 unsigned long keybind_lookup_keymap_command (const global_keymap_t * keymap, long key); 
     365void keybind_cmd_bind (GArray * keymap, const char *keybind, int action); 
     366int keybind_lookup_action (const char *name); 
     367const char *keybind_lookup_actionname (int action); 
     368const char *keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, int action); 
     369int keybind_lookup_keymap_command (const global_keymap_t * keymap, long key); 
    370370 
    371371/*** inline functions ****************************************************************************/ 
    372372 
  • lib/widget/buttonbar.c

    a b  
    266266{ 
    267267    if ((bb != NULL) && (idx >= 1) && (idx <= BUTTONBAR_LABELS_NUM)) 
    268268    { 
    269         unsigned long command = CK_IgnoreKey; 
     269        int command = CK_IgnoreKey; 
    270270 
    271271        if (keymap != NULL) 
    272272            command = keybind_lookup_keymap_command (keymap, KEY_F (idx)); 
  • lib/widget/buttonbar.h

    a b  
    2828    struct 
    2929    { 
    3030        char *text; 
    31         unsigned long command; 
     31        int command; 
    3232        Widget *receiver; 
    3333        int end_coord;          /* cumulative width of buttons so far */ 
    3434    } labels[BUTTONBAR_LABELS_NUM]; 
  • lib/widget/dialog.c

    a b  
    272272/* --------------------------------------------------------------------------------------------- */ 
    273273 
    274274static cb_ret_t 
    275 dlg_execute_cmd (WDialog * h, unsigned long command) 
     275dlg_execute_cmd (WDialog * h, int command) 
    276276{ 
    277277    cb_ret_t ret = MSG_HANDLED; 
    278278    switch (command) 
     
    341341static cb_ret_t 
    342342dlg_handle_key (WDialog * h, int d_key) 
    343343{ 
    344     unsigned long command; 
     344    int command; 
    345345 
    346346    command = keybind_lookup_keymap_command (dialog_map, d_key); 
    347347 
  • lib/widget/dialog.h

    a b  
    6464 
    6565/* get string representation of shortcut assigned  with command */ 
    6666/* as menu is a widget of dialog, ask dialog about shortcut string */ 
    67 typedef char *(*dlg_shortcut_str) (unsigned long command); 
     67typedef char *(*dlg_shortcut_str) (int command); 
    6868 
    6969/* get dialog name to show in dialog list */ 
    7070typedef char *(*dlg_title_str) (const WDialog * h, size_t len); 
  • lib/widget/input.c

    a b  
    679679/* --------------------------------------------------------------------------------------------- */ 
    680680 
    681681static cb_ret_t 
    682 input_execute_cmd (WInput * in, unsigned long command) 
     682input_execute_cmd (WInput * in, int command) 
    683683{ 
    684684    cb_ret_t res = MSG_HANDLED; 
    685685 
     
    11331133input_handle_char (WInput * in, int key) 
    11341134{ 
    11351135    cb_ret_t v; 
    1136     unsigned long command; 
     1136    int command; 
    11371137 
    11381138    if (quote != 0) 
    11391139    { 
     
    11771177int 
    11781178input_key_is_in_map (WInput * in, int key) 
    11791179{ 
    1180     unsigned long command; 
     1180    int command; 
    11811181 
    11821182    (void) in; 
    11831183 
  • lib/widget/listbox.c

    a b  
    256256/* --------------------------------------------------------------------------------------------- */ 
    257257 
    258258static cb_ret_t 
    259 listbox_execute_cmd (WListbox * l, unsigned long command) 
     259listbox_execute_cmd (WListbox * l, int command) 
    260260{ 
    261261    cb_ret_t ret = MSG_HANDLED; 
    262262    int i; 
     
    325325static cb_ret_t 
    326326listbox_key (WListbox * l, int key) 
    327327{ 
    328     unsigned long command; 
     328    int command; 
    329329 
    330330    if (l->list == NULL) 
    331331        return MSG_NOT_HANDLED; 
  • lib/widget/menu.c

    a b  
    5757{ 
    5858    unsigned char first_letter; 
    5959    hotkey_t text; 
    60     unsigned long command; 
     60    int command; 
    6161    char *shortcut; 
    6262}; 
    6363 
     
    774774/* --------------------------------------------------------------------------------------------- */ 
    775775 
    776776menu_entry_t * 
    777 menu_entry_create (const char *name, unsigned long command) 
     777menu_entry_create (const char *name, int command) 
    778778{ 
    779779    menu_entry_t *entry; 
    780780 
  • lib/widget/menu.h

    a b  
    4242 
    4343/*** declarations of public functions ************************************************************/ 
    4444 
    45 menu_entry_t *menu_entry_create (const char *name, unsigned long command); 
     45menu_entry_t *menu_entry_create (const char *name, int command); 
    4646void menu_entry_free (menu_entry_t * me); 
    4747 
    4848menu_t *create_menu (const char *name, GList * entries, const char *help_node); 
  • src/diffviewer/ydiff.c

    a b  
    31453145/* --------------------------------------------------------------------------------------------- */ 
    31463146 
    31473147static cb_ret_t 
    3148 dview_execute_cmd (WDiff * dview, unsigned long command) 
     3148dview_execute_cmd (WDiff * dview, int command) 
    31493149{ 
    31503150    cb_ret_t res = MSG_HANDLED; 
    31513151 
     
    33113311static cb_ret_t 
    33123312dview_handle_key (WDiff * dview, int key) 
    33133313{ 
    3314     unsigned long command; 
     3314    int command; 
    33153315 
    33163316#ifdef HAVE_CHARSET 
    33173317    key = convert_from_input_c (key); 
  • src/editor/edit.c

    a b  
    31853185 */ 
    31863186 
    31873187void 
    3188 edit_execute_key_command (WEdit * edit, unsigned long command, int char_for_insertion) 
     3188edit_execute_key_command (WEdit * edit, int command, int char_for_insertion) 
    31893189{ 
    31903190    if (command == CK_MacroStartRecord || command == CK_RepeatStartRecord 
    31913191        || (macro_index < 0 
     
    32343234   all of them. It also does not check for the Undo command. 
    32353235 */ 
    32363236void 
    3237 edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion) 
     3237edit_execute_cmd (WEdit * edit, int command, int char_for_insertion) 
    32383238{ 
    32393239    Widget *w = WIDGET (edit); 
    32403240 
  • src/editor/editcmd.c

    a b  
    34123412    /* edit is a pointer to the widget */ 
    34133413    if (edit != NULL) 
    34143414    { 
    3415         unsigned long command = macro_index < 0 ? CK_MacroStartRecord : CK_MacroStopRecord; 
     3415        int command = macro_index < 0 ? CK_MacroStartRecord : CK_MacroStopRecord; 
    34163416        edit_execute_key_command (edit, command, -1); 
    34173417    } 
    34183418} 
     
    34253425    /* edit is a pointer to the widget */ 
    34263426    if (edit != NULL) 
    34273427    { 
    3428         unsigned long command = macro_index < 0 ? CK_RepeatStartRecord : CK_RepeatStopRecord; 
     3428        int command = macro_index < 0 ? CK_RepeatStartRecord : CK_RepeatStopRecord; 
    34293429        edit_execute_key_command (edit, command, -1); 
    34303430    } 
    34313431} 
  • src/editor/edit-impl.h

    a b  
    234234void edit_goto_cmd (WEdit * edit); 
    235235gboolean eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark); 
    236236void edit_status (WEdit * edit, gboolean active); 
    237 void edit_execute_key_command (WEdit * edit, unsigned long command, int char_for_insertion); 
     237void edit_execute_key_command (WEdit * edit, int command, int char_for_insertion); 
    238238void edit_update_screen (WEdit * edit); 
    239239void edit_save_size (WEdit * edit); 
    240 gboolean edit_handle_move_resize (WEdit * edit, unsigned long command); 
     240gboolean edit_handle_move_resize (WEdit * edit, int command); 
    241241void edit_toggle_fullscreen (WEdit * edit); 
    242242void edit_move_to_line (WEdit * e, long line); 
    243243void edit_move_display (WEdit * e, long line); 
     
    286286void format_paragraph (WEdit * edit, gboolean force); 
    287287 
    288288/* either command or char_for_insertion must be passed as -1 */ 
    289 void edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion); 
     289void edit_execute_cmd (WEdit * edit, int command, int char_for_insertion); 
    290290 
    291291/*** inline functions ****************************************************************************/ 
    292292 
  • src/editor/editwidget.c

    a b  
    225225 */ 
    226226 
    227227static void 
    228 edit_window_move (WEdit * edit, unsigned long command) 
     228edit_window_move (WEdit * edit, int command) 
    229229{ 
    230230    Widget *w = WIDGET (edit); 
    231231    Widget *wh = WIDGET (w->owner); 
     
    265265 */ 
    266266 
    267267static void 
    268 edit_window_resize (WEdit * edit, unsigned long command) 
     268edit_window_resize (WEdit * edit, int command) 
    269269{ 
    270270    Widget *w = WIDGET (edit); 
    271271    Widget *wh = WIDGET (w->owner); 
     
    359359/* --------------------------------------------------------------------------------------------- */ 
    360360 
    361361static char * 
    362 edit_get_shortcut (unsigned long command) 
     362edit_get_shortcut (int command) 
    363363{ 
    364364    const char *ext_map; 
    365365    const char *shortcut = NULL; 
     
    708708/* --------------------------------------------------------------------------------------------- */ 
    709709 
    710710static cb_ret_t 
    711 edit_dialog_command_execute (WDialog * h, unsigned long command) 
     711edit_dialog_command_execute (WDialog * h, int command) 
    712712{ 
    713713    Widget *wh = WIDGET (h); 
    714714    gboolean ret = MSG_HANDLED; 
     
    817817static gboolean 
    818818edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch) 
    819819{ 
    820     unsigned long command = (unsigned long) CK_InsertChar; 
     820    int command = CK_InsertChar; 
    821821    int char_for_insertion = -1; 
    822822 
    823823    /* an ordinary insertable character */ 
     
    929929    *cmd = (int) command;       /* FIXME */ 
    930930    *ch = char_for_insertion; 
    931931 
    932     return !(command == (unsigned long) CK_InsertChar && char_for_insertion == -1); 
     932    return !(command == CK_InsertChar && char_for_insertion == -1); 
    933933} 
    934934 
    935935 
     
    10501050            if (edit_widget_is_editor (we)) 
    10511051            { 
    10521052                WEdit *e = (WEdit *) we; 
    1053                 unsigned long command; 
     1053                int command; 
    10541054 
    10551055                if (!e->extmod) 
    10561056                    command = keybind_lookup_keymap_command (editor_map, parm); 
     
    13791379 */ 
    13801380 
    13811381gboolean 
    1382 edit_handle_move_resize (WEdit * edit, unsigned long command) 
     1382edit_handle_move_resize (WEdit * edit, int command) 
    13831383{ 
    13841384    gboolean ret = FALSE; 
    13851385 
  • src/filemanager/midnight.c

    a b  
    407407/* --------------------------------------------------------------------------------------------- */ 
    408408 
    409409static char * 
    410 midnight_get_shortcut (unsigned long command) 
     410midnight_get_shortcut (int command) 
    411411{ 
    412412    const char *ext_map; 
    413413    const char *shortcut = NULL; 
     
    10951095/* --------------------------------------------------------------------------------------------- */ 
    10961096 
    10971097static cb_ret_t 
    1098 midnight_execute_cmd (Widget * sender, unsigned long command) 
     1098midnight_execute_cmd (Widget * sender, int command) 
    10991099{ 
    11001100    cb_ret_t res = MSG_HANDLED; 
    11011101 
     
    13951395static cb_ret_t 
    13961396midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) 
    13971397{ 
    1398     unsigned long command; 
     1398    int command; 
    13991399 
    14001400    switch (msg) 
    14011401    { 
  • src/filemanager/panel.c

    a b  
    33843384/* --------------------------------------------------------------------------------------------- */ 
    33853385 
    33863386static cb_ret_t 
    3387 panel_execute_cmd (WPanel * panel, unsigned long command) 
     3387panel_execute_cmd (WPanel * panel, int command) 
    33883388{ 
    33893389    int res = MSG_HANDLED; 
    33903390 
  • src/filemanager/tree.c

    a b  
    10291029/* --------------------------------------------------------------------------------------------- */ 
    10301030 
    10311031static cb_ret_t 
    1032 tree_execute_cmd (WTree * tree, unsigned long command) 
     1032tree_execute_cmd (WTree * tree, int command) 
    10331033{ 
    10341034    cb_ret_t res = MSG_HANDLED; 
    10351035 
  • src/help.c

    diff -ruN a/src/help.c b/src/help.c
    a b  
    858858/* --------------------------------------------------------------------------------------------- */ 
    859859 
    860860static cb_ret_t 
    861 help_execute_cmd (unsigned long command) 
     861help_execute_cmd (int command) 
    862862{ 
    863863    cb_ret_t ret = MSG_HANDLED; 
    864864 
     
    927927static cb_ret_t 
    928928help_handle_key (WDialog * h, int c) 
    929929{ 
    930     unsigned long command; 
     930    int command; 
    931931 
    932932    command = keybind_lookup_keymap_command (help_map, c); 
    933933    if ((command == CK_IgnoreKey) || (help_execute_cmd (command) == MSG_NOT_HANDLED)) 
  • src/setup.h

    a b  
    5858 
    5959typedef struct macro_action_t 
    6060{ 
    61     unsigned long action; 
     61    int action; 
    6262    int ch; 
    6363} macro_action_t; 
    6464 
  • src/viewer/actions_cmd.c

    a b  
    382382/* --------------------------------------------------------------------------------------------- */ 
    383383 
    384384static cb_ret_t 
    385 mcview_execute_cmd (WView * view, unsigned long command) 
     385mcview_execute_cmd (WView * view, int command) 
    386386{ 
    387387    int res = MSG_HANDLED; 
    388388 
     
    546546static cb_ret_t 
    547547mcview_handle_key (WView * view, int key) 
    548548{ 
    549     unsigned long command; 
     549    int command; 
    550550 
    551551#ifdef HAVE_CHARSET 
    552552    key = convert_from_input_c (key);