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

File mc-3641-cleanup-Wformat-signedness-hex_c.patch, 1.2 KB (added by andrew_b, 8 years ago)
  • lib/search/hex.c

    From 867417de2a2ccf2cb0106646e65d1f19aa12a49f Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sat, 17 Sep 2016 12:04:35 +0000
    Subject: [PATCH] (hex.c) Cleanup -Wformat-signedness warning
    
    Cleanup -Wformat-signedness warning.
    
    hex.c: In function 'mc_search__hex_translate_to_regex':
    hex.c:79:39: error: format '%x' expects argument of type 'unsigned int *', but argument 3 has type 'int *' [-Wformat=]
             if (sscanf (tmp_str + loop, "%x%n", &val, &ptr))
                                                    ^
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     lib/search/hex.c | 5 +++--
     1 file changed, 3 insertions(+), 2 deletions(-)
    
    diff --git a/lib/search/hex.c b/lib/search/hex.c
    index 9e3dbcd..d0d2abe 100644
    a b mc_search__hex_translate_to_regex (const GString * astr) 
    7373 
    7474    while (loop < tmp_str_len) 
    7575    { 
    76         int val, ptr; 
     76        unsigned int val; 
     77        int ptr; 
    7778 
    7879        /* cppcheck-suppress invalidscanf */ 
    7980        if (sscanf (tmp_str + loop, "%x%n", &val, &ptr)) 
    8081        { 
    81             if (val < -128 || val > 255) 
     82            if (val > 255) 
    8283                loop++; 
    8384            else 
    8485            {