Ticket #3693: mc-3641-cleanup-Wformat-signedness-editdraw_c.patch

File mc-3641-cleanup-Wformat-signedness-editdraw_c.patch, 3.4 KB (added by andrew_b, 5 years ago)
  • src/editor/editdraw.c

    From dd1378e7fd51efc46f861265d52ce257212688e7 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sat, 17 Sep 2016 12:06:59 +0000
    Subject: [PATCH] (editdraw.c) Cleanup -Wformat-signedness warning
    
    Cleanup -Wformat-signedness warning.
    
    editdraw.c:127:62: error: format '%d' expects argument of type 'int', but argument 4 has type 'unsigned int' [-Werror=format=]
                     g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X",
                                                                  ^
    
    editdraw.c:326:30: error: format '%d' expects argument of type 'int', but argument 2 has type 'unsigned int' [-Werror=format=]
                 tty_printf ("[%05d 0x%04X]", cur_utf, cur_utf);
                                  ^
    
    editdraw.c:334:30: error: format '%d' expects argument of type 'int', but argument 2 has type 'unsigned int' [-Werror=format=]
                 tty_printf ("[%05d 0x%04X]", (unsigned int) cur_byte, (unsigned int) cur_byte);
                                  ^
    
    editdraw.c:554:20: warning: conversion to 'unsigned int' from 'long int' may alter its value [-Wconversion]
             cur_line = edit->start_line + row;
                        ^~~~
    
    editdraw.c:557:59: error: format '%i' expects argument of type 'int', but argument 4 has type 'unsigned int' [-Werror=format=]
                 g_snprintf (line_stat, sizeof (line_stat), "%7i ", cur_line + 1);
                                                               ^
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/editor/editdraw.c | 12 ++++++------
     1 file changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/src/editor/editdraw.c b/src/editor/editdraw.c
    index ce6df58..899e3a8 100644
    a b status_string (WEdit * edit, char *s, int w) 
    124124            cur_utf = edit_buffer_get_utf (&edit->buffer, edit->buffer.curs1, &char_length); 
    125125            if (char_length > 0) 
    126126            { 
    127                 g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X", 
     127                g_snprintf (byte_str, sizeof (byte_str), "%04u 0x%03X", 
    128128                            (unsigned) cur_utf, (unsigned) cur_utf); 
    129129            } 
    130130            else 
    edit_status_window (WEdit * edit) 
    323323            cur_utf = edit_buffer_get_utf (&edit->buffer, edit->buffer.curs1, &char_length); 
    324324            if (char_length <= 0) 
    325325                cur_utf = edit_buffer_get_current_byte (&edit->buffer); 
    326             tty_printf ("[%05d 0x%04X]", cur_utf, cur_utf); 
     326            tty_printf ("[%05u 0x%04X]", cur_utf, cur_utf); 
    327327        } 
    328328#endif 
    329329        else 
    edit_status_window (WEdit * edit) 
    331331            unsigned char cur_byte; 
    332332 
    333333            cur_byte = edit_buffer_get_current_byte (&edit->buffer); 
    334             tty_printf ("[%05d 0x%04X]", (unsigned int) cur_byte, (unsigned int) cur_byte); 
     334            tty_printf ("[%05u 0x%04X]", (unsigned int) cur_byte, (unsigned int) cur_byte); 
    335335        } 
    336336    } 
    337337} 
    edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c 
    549549 
    550550    if (option_line_state) 
    551551    { 
    552         unsigned int cur_line; 
     552        long cur_line; 
    553553 
    554554        cur_line = edit->start_line + row; 
    555         if (cur_line <= (unsigned int) edit->buffer.lines) 
     555        if (cur_line <= edit->buffer.lines) 
    556556        { 
    557             g_snprintf (line_stat, sizeof (line_stat), "%7i ", cur_line + 1); 
     557            g_snprintf (line_stat, sizeof (line_stat), "%7ld ", cur_line + 1); 
    558558        } 
    559559        else 
    560560        {