Ticket #3641: mc-3641-cleanup-Wformat-signedness-serialize_c.patch

File mc-3641-cleanup-Wformat-signedness-serialize_c.patch, 4.5 KB (added by and, 8 years ago)
  • lib/serialize.c

    From b69a66c1980fbb13ccce14a33f53ec7b829f3900 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sat, 17 Sep 2016 12:05:09 +0000
    Subject: [PATCH] (serialize.c) Cleanup -Wformat-signedness warning
    
    Cleanup -Wformat-signedness warning.
    
    serialize.c: In function 'mc_serialize_str':
    serialize.c:116:34: error: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'size_t {aka long unsigned int}' [-Werror=format=]
         return g_strdup_printf ("%c%zd" SRLZ_DELIM_S "%s", prefix, strlen (data), data);
                                      ^
    serialize.c:130:19: error: format '%zd' expects argument of type 'signed size_t', but argument 5 has type 'size_t {aka long unsigned int}' [-Werror=format=]
     #define FUNC_NAME "mc_serialize_str()"
                       ^
    serialize.c:175:22: note: in expansion of macro 'FUNC_NAME'
                          FUNC_NAME
                          ^~~~~~~~~
    serialize.c:130:19: error: format '%zd' expects argument of type 'signed size_t', but argument 6 has type 'size_t {aka long unsigned int}' [-Werror=format=]
     #define FUNC_NAME "mc_serialize_str()"
                       ^
    serialize.c:175:22: note: in expansion of macro 'FUNC_NAME'
                          FUNC_NAME
                          ^~~~~~~~~
    serialize.c: In function 'mc_deserialize_config':
    serialize.c:267:19: error: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'size_t {aka long unsigned int}' [-Werror=format=]
     #define FUNC_NAME "mc_deserialize_config()"
                       ^
    serialize.c:269:35: note: in expansion of macro 'FUNC_NAME'
         prepend_error_message (error, FUNC_NAME " at %zd", current_position + 1); \
                                       ^~~~~~~~~
    serialize.c:301:17: note: in expansion of macro 'prepend_error_and_exit'
                     prepend_error_and_exit ();
                     ^~~~~~~~~~~~~~~~~~~~~~
    serialize.c:267:19: error: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'size_t {aka long unsigned int}' [-Werror=format=]
     #define FUNC_NAME "mc_deserialize_config()"
                       ^
    serialize.c:269:35: note: in expansion of macro 'FUNC_NAME'
         prepend_error_message (error, FUNC_NAME " at %zd", current_position + 1); \
                                       ^~~~~~~~~
    serialize.c:313:17: note: in expansion of macro 'prepend_error_and_exit'
                     prepend_error_and_exit ();
                     ^~~~~~~~~~~~~~~~~~~~~~
    serialize.c:267:19: error: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'size_t {aka long unsigned int}' [-Werror=format=]
     #define FUNC_NAME "mc_deserialize_config()"
                       ^
    serialize.c:269:35: note: in expansion of macro 'FUNC_NAME'
         prepend_error_message (error, FUNC_NAME " at %zd", current_position + 1); \
                                       ^~~~~~~~~
    serialize.c:325:17: note: in expansion of macro 'prepend_error_and_exit'
                     prepend_error_and_exit ();
                     ^~~~~~~~~~~~~~~~~~~~~~
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     lib/serialize.c | 6 +++---
     1 file changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/lib/serialize.c b/lib/serialize.c
    index 78504c5..df4edee 100644
    a b mc_serialize_str (const char prefix, const char *data, GError ** error) 
    113113        g_set_error (error, MC_ERROR, 0, "mc_serialize_str(): Input data is NULL."); 
    114114        return NULL; 
    115115    } 
    116     return g_strdup_printf ("%c%zd" SRLZ_DELIM_S "%s", prefix, strlen (data), data); 
     116    return g_strdup_printf ("%c%zu" SRLZ_DELIM_S "%s", prefix, strlen (data), data); 
    117117} 
    118118 
    119119/* --------------------------------------------------------------------------------------------- */ 
    mc_deserialize_str (const char prefix, const char *data, GError ** error) 
    173173    { 
    174174        g_set_error (error, MC_ERROR, 0, 
    175175                     FUNC_NAME 
    176                      ": Specified data length (%zd) is greater than actual data length (%zd)", 
     176                     ": Specified data length (%zu) is greater than actual data length (%zu)", 
    177177                     data_len, strlen (data)); 
    178178        return NULL; 
    179179    } 
    mc_serialize_config (const mc_config_t * data, GError ** error) 
    266266 
    267267#define FUNC_NAME "mc_deserialize_config()" 
    268268#define prepend_error_and_exit() { \ 
    269     prepend_error_message (error, FUNC_NAME " at %zd", current_position + 1); \ 
     269    prepend_error_message (error, FUNC_NAME " at %zu", current_position + 1); \ 
    270270                mc_config_deinit (ret_data); \ 
    271271                return NULL; \ 
    272272}