Ticket #4490: mc-4490-tar-sparse.c-fix-conditional-uninitialized-warning.patch

File mc-4490-tar-sparse.c-fix-conditional-uninitialized-warning.patch, 1.2 KB (added by and, 14 months ago)
  • src/vfs/tar/tar-sparse.c

    From 28971edfb1e980f8166c1a66bd4cd298e2ce1730 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Fri, 29 Sep 2023 12:37:05 +0000
    Subject: [PATCH] (tar-sparse.c) fix conditional-uninitialized warning
    
    tar-sparse.c:563:55: warning: variable 'rc' may be uninitialized when used here [-Wconditional-uninitialized]
        for (ext_p = h->oldgnu_header.isextended ? 1 : 0; rc == add_ok && ext_p != 0;
                                                          ^~
    tar-sparse.c:551:5: note: variable 'rc' is declared here
        enum oldgnu_add_status rc;
        ^
    
    Found by clang-16
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/vfs/tar/tar-sparse.c | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/src/vfs/tar/tar-sparse.c b/src/vfs/tar/tar-sparse.c
    index 0bc169b01..1e1eca1cd 100644
    a b oldgnu_get_sparse_info (tar_super_t * archive, struct tar_sparse_file *file) 
    548548    size_t i; 
    549549    union block *h = current_header; 
    550550    int ext_p; 
    551     enum oldgnu_add_status rc; 
     551    enum oldgnu_add_status rc = add_fail; 
    552552 
    553553    if (file->stat_info->sparse_map != NULL) 
    554554        g_array_set_size (file->stat_info->sparse_map, 0);