Ticket #3547: mc-3547-fish.c-cleanup-gcc-link-time-optimization-warning-v2.patch

File mc-3547-fish.c-cleanup-gcc-link-time-optimization-warning-v2.patch, 2.1 KB (added by and, 6 years ago)
  • src/vfs/fish/fish.c

    From 9671e6f91c5b64921c77549e2b3e3f699f6ce03b Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Thu, 31 Dec 2015 13:13:54 +0000
    Subject: [PATCH] fish.c: cleanup gcc link time optimization warning
    
    v2: consider andrew's comment
    
    will fix gcc LTO warning at:
      In function '__read_alias',
          inlined from 'fish_linear_abort.isra.0' at fish.c:1047:15:
      /usr/include/bits/unistd.h:39:9: error: call to '__read_chk_warn' declared with attribute warning: read called with bigger length than size of the destination buffer [-Werror]
         return __read_chk (__fd, __buf, __nbytes, __bos0 (__buf));
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/vfs/fish/fish.c | 22 +++++++++++-----------
     1 file changed, 11 insertions(+), 11 deletions(-)
    
    diff --git a/src/vfs/fish/fish.c b/src/vfs/fish/fish.c
    index 1172f31..8eb8cc8 100644
    a b fish_linear_abort (struct vfs_class *me, vfs_file_handler_t * fh) 
    10341034{ 
    10351035    fish_fh_data_t *fish = (fish_fh_data_t *) fh->data; 
    10361036    struct vfs_s_super *super = FH_SUPER; 
    1037     char buffer[BUF_8K]; 
     1037    char *buf; 
    10381038    ssize_t n; 
    10391039 
    10401040    vfs_print_message ("%s", _("Aborting transfer...")); 
    10411041 
    1042     do 
     1042    buf = g_malloc (BUF_8K); 
     1043    while ((fish->total - fish->got) != 0) 
    10431044    { 
    1044         n = MIN ((off_t) sizeof (buffer), (fish->total - fish->got)); 
    1045         if (n != 0) 
    1046         { 
    1047             n = read (SUP->sockr, buffer, n); 
    1048             if (n < 0) 
    1049                 return; 
    1050             fish->got += n; 
    1051         } 
     1045        if (sizeof (*buf) > (size_t) (fish->total - fish->got)) 
     1046           buf = g_try_realloc (buf, (fish->total - fish->got)); 
     1047        n = read (SUP->sockr, buf, sizeof (*buf)); 
     1048        if (n < 0) 
     1049            goto ret; 
     1050        fish->got += n; 
    10521051    } 
    1053     while (n != 0); 
    10541052 
    10551053    if (fish_get_reply (me, SUP->sockr, NULL, 0) != COMPLETE) 
    10561054        vfs_print_message ("%s", _("Error reported after abort.")); 
    10571055    else 
    10581056        vfs_print_message ("%s", _("Aborted transfer would be successful.")); 
     1057  ret: 
     1058    g_free(buf); 
    10591059} 
    10601060 
    10611061/* --------------------------------------------------------------------------------------------- */