From 985125ab3301705d04d717176e28ebe8ee214f7a Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Sat, 10 Nov 2018 09:02:21 +0000 Subject: [PATCH] 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". --- src/util/run.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util/run.cpp b/src/util/run.cpp index 9644ec25c3..8783fd3c03 100644 --- a/src/util/run.cpp +++ b/src/util/run.cpp @@ -53,9 +53,8 @@ using fdt = int; /// open given file to replace either stdin, stderr, stdout static fdt stdio_redirection(int fd, const std::string &file) { - fdt result_fd; - #ifdef _WIN32 + fdt result_fd = INVALID_HANDLE_VALUE; std::string name; SECURITY_ATTRIBUTES SecurityAttributes; @@ -142,7 +141,7 @@ static fdt stdio_redirection(int fd, const std::string &file) UNREACHABLE; } - result_fd = open(file.c_str(), flags, mode); + const fdt result_fd = open(file.c_str(), flags, mode); if(result_fd == -1) perror(("Failed to open " + name + " file " + file).c_str());