driver/main: Use separate variables for error checking in main()

Avoids reusing the same variable for two different areas of behavior and
uses separately named variables. This can help debugging if the first
condition isn't true, but the tool run condition is true, as it provides
an error count to compare against.
This commit is contained in:
Lioncash 2019-08-19 21:57:22 -04:00
parent 7647fa3ca6
commit d3ac48715f
1 changed files with 5 additions and 7 deletions

View File

@ -331,27 +331,25 @@ int main(int argc, const char** argv)
} }
/* Construct selected tool */ /* Construct selected tool */
size_t ErrorRef = logvisor::ErrorCount; const size_t MakeToolErrorRef = logvisor::ErrorCount;
auto tool = MakeSelectedTool(argv[1], info); auto tool = MakeSelectedTool(argv[1], info);
if (logvisor::ErrorCount > MakeToolErrorRef) {
if (logvisor::ErrorCount > ErrorRef) {
#if WIN_PAUSE #if WIN_PAUSE
system("PAUSE"); system("PAUSE");
#endif #endif
return 1; return 1;
} }
if (info.verbosityLevel) { if (info.verbosityLevel) {
LogModule.report(logvisor::Info, fmt(_SYS_STR("Constructed tool '{}' {}\n")), tool->toolName(), LogModule.report(logvisor::Info, fmt(_SYS_STR("Constructed tool '{}' {}\n")), tool->toolName(),
info.verbosityLevel); info.verbosityLevel);
} }
/* Run tool */ /* Run tool */
ErrorRef = logvisor::ErrorCount; const size_t RunToolErrorRef = logvisor::ErrorCount;
ToolPtr = tool.get(); ToolPtr = tool.get();
int retval = tool->run(); const int retval = tool->run();
ToolPtr = nullptr; ToolPtr = nullptr;
if (logvisor::ErrorCount > ErrorRef) { if (logvisor::ErrorCount > RunToolErrorRef) {
hecl::blender::Connection::Shutdown(); hecl::blender::Connection::Shutdown();
#if WIN_PAUSE #if WIN_PAUSE
system("PAUSE"); system("PAUSE");