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

File mc-3547-fish.c-cleanup-gcc-link-time-optimization-warning.patch, 2.1 KB (added by and, 8 years ago)

tested with fish shell and large file transfer abort

  • src/vfs/fish/fish.c

    From b1cd6d5441af1c10951ba9524bbbcdbf2f0db529 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sat, 19 Dec 2015 13:23:23 +0000
    Subject: [PATCH]  fish.c: cleanup gcc link time optimization warning
    
    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 | 23 ++++++++++++++---------
     1 file changed, 14 insertions(+), 9 deletions(-)
    
    diff --git a/src/vfs/fish/fish.c b/src/vfs/fish/fish.c
    index 1172f31..8c4401d 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; 
     1038    size_t bufsize = BUF_8K; 
    10381039    ssize_t n; 
    10391040 
    10401041    vfs_print_message ("%s", _("Aborting transfer...")); 
    10411042 
    1042     do 
     1043    buf = g_malloc (bufsize * sizeof *buf); 
     1044    while ((fish->total - fish->got) != 0) 
    10431045    { 
    1044         n = MIN ((off_t) sizeof (buffer), (fish->total - fish->got)); 
    1045         if (n != 0) 
     1046        if (bufsize > (size_t) (fish->total - fish->got)) 
    10461047        { 
    1047             n = read (SUP->sockr, buffer, n); 
    1048             if (n < 0) 
    1049                 return; 
    1050             fish->got += n; 
     1048           g_free(buf); 
     1049           bufsize = (size_t) (fish->total - fish->got); 
     1050           buf = g_malloc (bufsize * sizeof *buf); 
    10511051        } 
     1052        n = read (SUP->sockr, buf, bufsize); 
     1053        if (n < 0) 
     1054            goto ret; 
     1055        fish->got += n; 
    10521056    } 
    1053     while (n != 0); 
    10541057 
    10551058    if (fish_get_reply (me, SUP->sockr, NULL, 0) != COMPLETE) 
    10561059        vfs_print_message ("%s", _("Error reported after abort.")); 
    10571060    else 
    10581061        vfs_print_message ("%s", _("Aborted transfer would be successful.")); 
     1062  ret: 
     1063    g_free(buf); 
    10591064} 
    10601065 
    10611066/* --------------------------------------------------------------------------------------------- */