Skip to content

Commit 985125a

Browse files
committed
Avoid warning about result_fd being possibly uninitialized
The default branch of the Windows version indeed did not initialize result_fd, but is guarded by "UNREACHABLE".
1 parent cfb757c commit 985125a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/util/run.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ using fdt = int;
5353
/// open given file to replace either stdin, stderr, stdout
5454
static fdt stdio_redirection(int fd, const std::string &file)
5555
{
56-
fdt result_fd;
57-
5856
#ifdef _WIN32
57+
fdt result_fd = INVALID_HANDLE_VALUE;
5958
std::string name;
6059

6160
SECURITY_ATTRIBUTES SecurityAttributes;
@@ -142,7 +141,7 @@ static fdt stdio_redirection(int fd, const std::string &file)
142141
UNREACHABLE;
143142
}
144143

145-
result_fd = open(file.c_str(), flags, mode);
144+
const fdt result_fd = open(file.c_str(), flags, mode);
146145

147146
if(result_fd == -1)
148147
perror(("Failed to open " + name + " file " + file).c_str());

0 commit comments

Comments
 (0)