Commit 5334f5ca authored by Jan Möbius's avatar Jan Möbius

Some cppcheck fixes

parent b5a167d0
...@@ -111,35 +111,64 @@ ...@@ -111,35 +111,64 @@
#ifdef WIN32 #ifdef WIN32
void attachConsole() void attachConsole()
{ {
//try to attach the console of the parent process //try to attach the console of the parent process
if (AttachConsole(-1)) if (AttachConsole(-1))
{ {
//if the console was attached change stdinput and output //if the console was attached change stdinput and output
freopen("CONIN$", "r", stdin); FILE* check = freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout); if (check) {
freopen("CONOUT$", "w", stderr); std::cerr << "Error reopening stdin" << std::endl;
} }
else ckeck = freopen("CONOUT$", "w", stdout);
{ if (check) {
//create and attach a new console if needed std::cerr << "Error reopening stdout" << std::endl;
#ifndef NDEBUG }
//always open a console in debug mode check = freopen("CONOUT$", "w", stderr);
AllocConsole(); if (check) {
freopen("CONIN$", "r", stdin); std::cerr << "Error reopening stderr" << std::endl;
freopen("CONOUT$", "w", stdout); }
freopen("CONOUT$", "w", stderr); }
return; else
#endif {
if (OpenFlipper::Options::logToConsole()) //create and attach a new console if needed
{ #ifndef NDEBUG
AllocConsole(); //always open a console in debug mode
freopen("CONIN$", "r", stdin); AllocConsole();
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr); FILE* check = freopen("CONIN$", "r", stdin);
} if (check) {
} std::cerr << "Error reopening stdin" << std::endl;
} }
ckeck = freopen("CONOUT$", "w", stdout);
if (check) {
std::cerr << "Error reopening stdout" << std::endl;
}
check = freopen("CONOUT$", "w", stderr);
if (check) {
std::cerr << "Error reopening stderr" << std::endl;
}
return;
#endif
if (OpenFlipper::Options::logToConsole())
{
AllocConsole();
FILE* check = freopen("CONIN$", "r", stdin);
if (check) {
std::cerr << "Error reopening stdin" << std::endl;
}
ckeck = freopen("CONOUT$", "w", stdout);
if (check) {
std::cerr << "Error reopening stdout" << std::endl;
}
check = freopen("CONOUT$", "w", stderr);
if (check) {
std::cerr << "Error reopening stderr" << std::endl;
}
}
}
}
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment