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) |
69 | 69 | { |
70 | 70 | int i = start; |
71 | 71 | char delimiter = '\0'; |
72 | | char delimopen; |
| 72 | char delimopen= '\0'; |
73 | 73 | int nestdelim = 0; |
74 | 74 | |
75 | 75 | if (member (string[i], "()\n")) /* XXX - included \n, but why? been here forever */ |
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, |
2263 | 2263 | mode_t src_mode = 0; /* The mode of the source file */ |
2264 | 2264 | struct stat src_stat, dst_stat; |
2265 | 2265 | mc_timesbuf_t times; |
2266 | | unsigned long attrs; |
| 2266 | unsigned long attrs = 0; |
2267 | 2267 | gboolean attrs_ok = ctx->preserve; |
2268 | 2268 | gboolean dst_exists = FALSE, appending = FALSE; |
2269 | 2269 | off_t file_size = -1; |
… |
… |
copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha |
2939 | 2939 | { |
2940 | 2940 | struct vfs_dirent *next; |
2941 | 2941 | struct stat dst_stat, src_stat; |
2942 | | unsigned long attrs; |
| 2942 | unsigned long attrs = 0; |
2943 | 2943 | gboolean attrs_ok = ctx->preserve; |
2944 | 2944 | DIR *reading; |
2945 | 2945 | FileProgressStatus return_status = FILE_CONT; |