Ticket #3641: mc-3641-cleanup-compile-warning-background_c.patch

File mc-3641-cleanup-compile-warning-background_c.patch, 3.1 KB (added by and, 8 years ago)
  • src/background.c

    From 0529184996f36819d860c9692d516930ce932102 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sat, 16 Jul 2016 13:24:25 +0000
    Subject: [PATCH] (background.c) Cleanup some compile warnings
    
    background.c:273:34: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
            data[i] = g_malloc (size + 1);
                      ~~~~~~~~  ~~~~~^~~
    background.c:274:32: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
            if (read (fd, data[i], size) != size)
                ~~~~               ^~~~
    background.c:382:51: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
                    ret = write (to_child_fd, resstr, len);
                          ~~~~~                       ^~~
    background.c:379:19: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                len = strlen (resstr);
                    ~ ^~~~~~~~~~~~~~~
    background.c:446:40: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
            ret = write (parent_fd, value, len);
                  ~~~~~                    ^~~
    background.c:474:39: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
                (write (parent_fd, value, len) != len))
                 ~~~~~                    ^~~
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/background.c | 12 ++++++------
     1 file changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/src/background.c b/src/background.c
    index 54b6e7d..d341a28 100644
    a b background_attention (int fd, void *closure) 
    264264 
    265265    for (i = 0; i < argc; i++) 
    266266    { 
    267         int size; 
     267        unsigned int size; 
    268268 
    269269        if (read (fd, &size, sizeof (size)) != sizeof (size)) 
    270270        { 
    background_attention (int fd, void *closure) 
    348348    } 
    349349    else if (type == Return_String) 
    350350    { 
    351         int len; 
     351        size_t len; 
    352352        char *resstr = NULL; 
    353353 
    354354        /* FIXME: string routines should also use the Foreground/Background 
    parent_va_call (void *routine, gpointer data, int argc, va_list ap) 
    437437    parent_call_header (routine, argc, Return_Integer, ctx); 
    438438    for (i = 0; i < argc; i++) 
    439439    { 
    440         int len; 
     440        size_t len; 
    441441        void *value; 
    442442 
    443         len = va_arg (ap, int); 
     443        len = va_arg (ap, size_t); 
    444444        value = va_arg (ap, void *); 
    445445        ret = write (parent_fd, &len, sizeof (len)); 
    446446        ret = write (parent_fd, value, len); 
    parent_va_call_string (void *routine, int argc, va_list ap) 
    465465    parent_call_header (routine, argc, Return_String, NULL); 
    466466    for (i = 0; i < argc; i++) 
    467467    { 
    468         int len; 
     468        unsigned int len; 
    469469        void *value; 
    470470 
    471         len = va_arg (ap, int); 
     471        len = va_arg (ap, unsigned int); 
    472472        value = va_arg (ap, void *); 
    473473        if ((write (parent_fd, &len, sizeof (len)) != sizeof (len)) || 
    474474            (write (parent_fd, value, len) != len))