diff --git a/Core/CLI/src/cli_visualize.cpp b/Core/CLI/src/cli_visualize.cpp index db45ca4155..be54a26124 100644 --- a/Core/CLI/src/cli_visualize.cpp +++ b/Core/CLI/src/cli_visualize.cpp @@ -264,7 +264,11 @@ bool CommandLineInterface::DoVisualize(const std::string* pArg1, const std::stri lSystemCommand += lFileName; lSystemCommand += '.'; lSystemCommand += thisAgent->visualizationManager->settings->image_type->get_value(); - system(lSystemCommand.c_str()); + if (system(lSystemCommand.c_str()) != 0) + { + thisAgent->visualizationManager->clear_visualization(); + return SetError("Error: Could not generate visualization image because `dot` command failed. Do you have GraphViz installed?!\n"); + } } if (thisAgent->visualizationManager->settings->launch_viewer->get_value()) { @@ -272,14 +276,20 @@ bool CommandLineInterface::DoVisualize(const std::string* pArg1, const std::stri lSystemCommand += lFileName; lSystemCommand += '.'; lSystemCommand += thisAgent->visualizationManager->settings->image_type->get_value(); - system(lSystemCommand.c_str()); + if (system(lSystemCommand.c_str()) != 0) { + thisAgent->visualizationManager->clear_visualization(); + return SetError("Error: Could not generate visualization image because failed to open file generated by `dot` command.\n"); + } } if (thisAgent->visualizationManager->settings->launch_editor->get_value()) { lSystemCommand = "open "; lSystemCommand += lFileName; lSystemCommand += ".gv"; - system(lSystemCommand.c_str()); + if (system(lSystemCommand.c_str()) != 0) + { + return SetError("Error: Could not open .gv file for editing.\n"); + } } if (thisAgent->visualizationManager->settings->print_gv->get_value()) { diff --git a/Core/ClientSML/src/sml_ClientAgent.cpp b/Core/ClientSML/src/sml_ClientAgent.cpp index 7ad273743d..ba9c805088 100644 --- a/Core/ClientSML/src/sml_ClientAgent.cpp +++ b/Core/ClientSML/src/sml_ClientAgent.cpp @@ -1535,7 +1535,11 @@ bool Agent::SpawnDebugger(int port, const char* jarpath) #ifdef _MSC_VER GetCurrentDirectory(4096, buffer); #else - getcwd(buffer, 4096); + if (getcwd(buffer, 4096) != buffer) + { + perror("getcwd"); + return false; + } #endif std::string debuggerPath = buffer; @@ -1705,7 +1709,11 @@ bool Agent::SpawnDebugger(int port, const char* jarpath) } char buffer[4096 + 1]; - getcwd(buffer, 4096); + if (getcwd(buffer, 4096) != buffer) + { + perror("getcwd"); + return false; + } path += ":"; path += buffer; diff --git a/Core/SoarKernel/src/explanation_based_chunking/ebc_identity.cpp b/Core/SoarKernel/src/explanation_based_chunking/ebc_identity.cpp index 37319e71f6..4b1a59a88e 100644 --- a/Core/SoarKernel/src/explanation_based_chunking/ebc_identity.cpp +++ b/Core/SoarKernel/src/explanation_based_chunking/ebc_identity.cpp @@ -89,7 +89,7 @@ void Identity::set_operational_cond(condition* pCond, WME_Field pField) joined_identity->touch(); } -uint64_t get_joined_identity_id(Identity* pIdentity) { if (!pIdentity) return NULL_IDENTITY_SET; else return pIdentity->get_identity(); } -Identity* get_joined_identity(Identity* pIdentity) { if (!pIdentity) return NULL; else return pIdentity->joined_identity;} -uint64_t get_joined_identity_chunk_inst_id(Identity* pIdentity) { if (!pIdentity) return NULL_IDENTITY_SET; else return pIdentity->get_clone_identity();} +uint64_t get_joined_identity_id(Identity* pIdentity) { if (!pIdentity) return NULL_IDENTIFIER_ID; else return pIdentity->get_identity(); } +Identity* get_joined_identity(Identity* pIdentity) { if (!pIdentity) return NULL_IDENTITY_SET; else return pIdentity->joined_identity;} +uint64_t get_joined_identity_chunk_inst_id(Identity* pIdentity) { if (!pIdentity) return NULL_IDENTIFIER_ID; else return pIdentity->get_clone_identity();} diff --git a/Core/SoarKernel/src/shared/memory_manager.cpp b/Core/SoarKernel/src/shared/memory_manager.cpp index 56205642e5..5e85be937e 100644 --- a/Core/SoarKernel/src/shared/memory_manager.cpp +++ b/Core/SoarKernel/src/shared/memory_manager.cpp @@ -271,14 +271,14 @@ void* Memory_Manager::allocate_memory(size_t size, int usage_code) if (p == NULL) { char msg[BUFFER_MSG_SIZE]; - SNPRINTF(msg, BUFFER_MSG_SIZE, "\nmem.c: Error: Tried but failed to allocate %zu bytes of memory.\n", size); + SNPRINTF(msg, BUFFER_MSG_SIZE, "\nmemory_manager.cpp: Error: Tried but failed to allocate %zu bytes of memory.\n", size); msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */ abort_with_fatal_error_noagent(msg); } if (reinterpret_cast(p) & 3) { char msg[BUFFER_MSG_SIZE]; - strncpy(msg, "\nmem.c: Error: Memory allocator returned an address that's not a multiple of 4.\n", BUFFER_MSG_SIZE); + strncpy(msg, "\nmemory_manager.cpp: Error: Memory allocator returned an address that's not a multiple of 4.\n", BUFFER_MSG_SIZE); msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */ abort_with_fatal_error_noagent(msg); } diff --git a/SConstruct b/SConstruct index 6a0fb63ade..1f8f7b1e06 100644 --- a/SConstruct +++ b/SConstruct @@ -194,6 +194,7 @@ if GetOption('cc') != None: env.Replace(CC=GetOption('cc')) elif sys.platform == 'darwin': env.Replace(CC='clang') + if GetOption('cxx') != None: env.Replace(CXX=GetOption('cxx')) elif sys.platform == 'darwin': @@ -217,6 +218,8 @@ lnflags = [] libs = ['Soar'] if compiler == 'g++': libs += [ 'pthread', 'dl', 'm' ] + # causes some spurious warnings; TODO: revisit and re-enable if newer compiler version fixes that + cflags.append('-Wno-stringop-overflow') if GetOption('nosvs'): cflags.append('-DNO_SVS') if GetOption('defflags'): diff --git a/UnitTests/TestHarness/TestHelpers.cpp b/UnitTests/TestHarness/TestHelpers.cpp index bb866a0889..9d8b743e11 100644 --- a/UnitTests/TestHarness/TestHelpers.cpp +++ b/UnitTests/TestHarness/TestHelpers.cpp @@ -47,7 +47,11 @@ void setCWDToEnv() { if (getenv("LIBSOAR") != nullptr) { - chdir(getenv("LIBSOAR")); + if (chdir(getenv("LIBSOAR")) != 0) { + std::cerr << "Could not change directory to getenv(\"LIBSOAR\") (" << getenv("LIBSOAR") << ")" << std::endl; + perror("chdir"); + // no further action; tests might work fine anyway if the CWD is already correct + } } } @@ -55,7 +59,7 @@ void printDebugInformation(std::stringstream& output, sml::Agent* agent) { if (!agent) return; - + // output << "============================================================" << std::endl << std::endl; // output << "Debug Information" << std::endl << std::endl; // output << "============================================================" << std::endl << std::endl; @@ -94,37 +98,37 @@ namespace TestHelpers #ifdef __GNUG__ std::string demangle(const char* name) { - + int status = -1; - + std::unique_ptr res { abi::__cxa_demangle(name, NULL, NULL, &status), std::free }; - + return (status==0) ? res.get() : name ; } // VS2013 + #elif _MSC_VER - + std::string demangle(const char* name) { std::string result = name; result = result.substr(result.find_last_of(" ")+1, std::string::npos); - + return result; } // Unknown #else - + // does nothing if not g++ std::string demangle(const char* name) { return name; } - + #endif - + };