Merge pull request #3313 from tautschnig/vs-uninit

Avoid warning about result_fd being possibly uninitialized [blocks: #2310]
This commit is contained in:
Michael Tautschnig 2018-11-10 12:13:43 +00:00 committed by GitHub
commit 386ea88275
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -53,9 +53,8 @@ using fdt = int;
/// open given file to replace either stdin, stderr, stdout /// open given file to replace either stdin, stderr, stdout
static fdt stdio_redirection(int fd, const std::string &file) static fdt stdio_redirection(int fd, const std::string &file)
{ {
fdt result_fd;
#ifdef _WIN32 #ifdef _WIN32
fdt result_fd = INVALID_HANDLE_VALUE;
std::string name; std::string name;
SECURITY_ATTRIBUTES SecurityAttributes; SECURITY_ATTRIBUTES SecurityAttributes;
@ -142,7 +141,7 @@ static fdt stdio_redirection(int fd, const std::string &file)
UNREACHABLE; UNREACHABLE;
} }
result_fd = open(file.c_str(), flags, mode); const fdt result_fd = open(file.c_str(), flags, mode);
if(result_fd == -1) if(result_fd == -1)
perror(("Failed to open " + name + " file " + file).c_str()); perror(("Failed to open " + name + " file " + file).c_str());