Skip to content

Commit 386ea88

Browse files
authored
Merge pull request #3313 from tautschnig/vs-uninit
Avoid warning about result_fd being possibly uninitialized [blocks: #2310]
2 parents 2c37acb + 985125a commit 386ea88

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)