Ticket #4524: 0001-clang-fix-Wconditional-uninitialized-warnings.patch

File 0001-clang-fix-Wconditional-uninitialized-warnings.patch, 2.9 KB (added by zaytsev, 5 months ago)
  • lib/strutil/tokenize.c

    From bfb8efb9c4310334e376ee8550c70be2d7cb77b2 Mon Sep 17 00:00:00 2001
    From: "Yury V. Zaytsev" <yury@shurup.com>
    Date: Thu, 30 May 2024 21:20:48 +0200
    Subject: [PATCH] clang: fix `-Wconditional-uninitialized` warnings
    
    ../../../src/filemanager/file.c:2402:61: warning: variable 'attrs' may be uninitialized when used here [-Wconditional-uninitialized]
                    while (attrs_ok && mc_fsetflags (dst_vpath, attrs) != 0 && !ctx->skip_all)
                                                                ^~~~~
    ../../../src/filemanager/file.c:2266:24: note: initialize the variable 'attrs' to silence this warning
        unsigned long attrs;
                           ^
                            = 0
    
    ../../../src/filemanager/file.c:3227:38: warning: variable 'attrs' may be uninitialized when used here [-Wconditional-uninitialized]
                mc_fsetflags (dst_vpath, attrs);
                                         ^~~~~
    ../../../src/filemanager/file.c:2942:24: note: initialize the variable 'attrs' to silence this warning
        unsigned long attrs;
                           ^
                            = 0
    
    ../../../lib/strutil/tokenize.c:163:44: warning: variable 'delimopen' may be uninitialized when used here [-Wconditional-uninitialized]
            if (nestdelim != 0 && string[i] == delimopen)
                                               ^~~~~~~~~
    ../../../lib/strutil/tokenize.c:72:19: note: initialize the variable 'delimopen' to silence this warning
        char delimopen;
                      ^
                       = '\0'
    ---
     lib/strutil/tokenize.c | 2 +-
     src/filemanager/file.c | 4 ++--
     2 files changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/lib/strutil/tokenize.c b/lib/strutil/tokenize.c
    index 3c861dee0..7cc1fef0f 100644
    a b str_tokenize_word (const char *string, int start) 
    6969{ 
    7070    int i = start; 
    7171    char delimiter = '\0'; 
    72     char delimopen; 
     72    char delimopen= '\0'; 
    7373    int nestdelim = 0; 
    7474 
    7575    if (member (string[i], "()\n"))     /* XXX - included \n, but why? been here forever */ 
  • src/filemanager/file.c

    diff --git a/src/filemanager/file.c b/src/filemanager/file.c
    index 41bd86cab..ffc2a6611 100644
    a b copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx, 
    22632263    mode_t src_mode = 0;        /* The mode of the source file */ 
    22642264    struct stat src_stat, dst_stat; 
    22652265    mc_timesbuf_t times; 
    2266     unsigned long attrs; 
     2266    unsigned long attrs = 0; 
    22672267    gboolean attrs_ok = ctx->preserve; 
    22682268    gboolean dst_exists = FALSE, appending = FALSE; 
    22692269    off_t file_size = -1; 
    copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha 
    29392939{ 
    29402940    struct vfs_dirent *next; 
    29412941    struct stat dst_stat, src_stat; 
    2942     unsigned long attrs; 
     2942    unsigned long attrs = 0; 
    29432943    gboolean attrs_ok = ctx->preserve; 
    29442944    DIR *reading; 
    29452945    FileProgressStatus return_status = FILE_CONT;