diff --git a/DDCond/src/ConditionsTextRepository.cpp b/DDCond/src/ConditionsTextRepository.cpp index 1889c8c97e62ceecdd43542ec48491f677d9937a..d9369c155f39296abe4ea5a63b9836fbf77edb23 100644 --- a/DDCond/src/ConditionsTextRepository.cpp +++ b/DDCond/src/ConditionsTextRepository.cpp @@ -154,6 +154,8 @@ namespace { text[0] = 0; in.getline(text,sizeof(text),'\n'); if ( in.good() ) { + size_t idx_nam = 9+siz_nam<sizeof(text)-1 ? 9+siz_nam : 0; + size_t idx_add = 10+siz_nam+siz_add<sizeof(text)-1 ? 10+siz_nam+siz_add : 0; if ( 9+siz_nam >= sizeof(text) ) except("ConditionsTextRepository","Inconsistent input data in %s: %s -> (%lld,%lld,%lld)", __FILE__, input.c_str(), siz_nam, siz_add, siz_tot); @@ -162,9 +164,9 @@ namespace { __FILE__, input.c_str(), siz_nam, siz_add, siz_tot); else if ( siz_tot ) { // Direct access mode with fixed record size - text[8] = text[9+siz_nam] = text[10+siz_nam+siz_add] = 0; + text[8] = text[idx_nam] = text[idx_add] = 0; e.name = text+9; - e.address = text+10+siz_nam; + e.address = text+idx_nam+1; if ( (idx=e.name.find(' ')) != string::npos ) e.name[idx]=0; if ( (idx=e.address.find(' ')) != string::npos ) diff --git a/DDCond/src/plugins/ConditionsRepositoryParser.cpp b/DDCond/src/plugins/ConditionsRepositoryParser.cpp index fee0e8ca814368142f0a7157f3aa3a1fab49e5a3..cefca3880b3d99c0d1a2b7cd0894bf8bc26c5b9b 100644 --- a/DDCond/src/plugins/ConditionsRepositoryParser.cpp +++ b/DDCond/src/plugins/ConditionsRepositoryParser.cpp @@ -30,6 +30,7 @@ // C/C++ include files #include <stdexcept> +#include <climits> /// DD4hep namespace declaration namespace DD4hep { @@ -209,7 +210,7 @@ namespace DD4hep { template <> void Converter<iov_type>::operator()(xml_h element) const { xml_dim_t e = element; string nam = e.nameStr(); - size_t id = e.id(); + size_t id = e.id() > 0 ? e.id() : INT_MAX; ConversionArg* arg = _param<ConversionArg>(); printout(s_parseLevel,"XMLConditions","++ Registering IOV type: [%d]: %s",int(id),nam.c_str()); const IOVType* iov_type = arg->manager.registerIOVType(id,nam).second; diff --git a/DDCore/include/DD4hep/Plugins.h b/DDCore/include/DD4hep/Plugins.h index 4da6f87b3d1f35a2a12e6c531fd28ae463d963da..588dad6da548517aeaba6cf520f3fc0beeba8d64 100644 --- a/DDCore/include/DD4hep/Plugins.h +++ b/DDCore/include/DD4hep/Plugins.h @@ -77,7 +77,7 @@ namespace DD4hep { struct PluginDebug { int m_debug; /// Default constructor - PluginDebug(int dbg = 2); + PluginDebug(int dbg = 2) noexcept(false); /// Default destructor ~PluginDebug(); /// Helper to check factory existence diff --git a/DDCore/src/Plugins.cpp b/DDCore/src/Plugins.cpp index 5b69d62188bd38ea2e0f757ce3eb66b9eb175e06..2251e754de46a1af48e1a65cb09561079972ade6 100644 --- a/DDCore/src/Plugins.cpp +++ b/DDCore/src/Plugins.cpp @@ -135,12 +135,12 @@ namespace { } /// Default constructor -PluginDebug::PluginDebug(int dbg) : m_debug(0) { +PluginDebug::PluginDebug(int dbg) noexcept(false) : m_debug(0) { m_debug = PluginInterface::instance().setDebug(dbg); } /// Default destructor -PluginDebug::~PluginDebug() { +PluginDebug::~PluginDebug() { PluginInterface::instance().setDebug(m_debug); } diff --git a/DDDB/src/DDDBFileReader.cpp b/DDDB/src/DDDBFileReader.cpp index c8bef7ae4f55d4267d893003f2cd7d1f9d64a89b..3499c8da0f7d8cd1c032e74706808934f5c5a9a5 100644 --- a/DDDB/src/DDDBFileReader.cpp +++ b/DDDB/src/DDDBFileReader.cpp @@ -68,10 +68,10 @@ int DD4hep::DDDB::DDDBFileReader::getObject(const std::string& system_id, std::string& buffer) { std::string path = m_directory+system_id; - struct stat buff; - if ( 0 == ::stat(path.c_str(), &buff) ) { - int fid = ::open(path.c_str(), O_RDONLY); - if ( fid > 0 ) { + int fid = ::open(path.c_str(), O_RDONLY); + if ( fid != -1 ) { + struct stat buff; + if ( 0 == ::fstat(fid, &buff) ) { int done = 0, len = buff.st_size; char* b = new char[len+1]; b[0] = 0; @@ -88,6 +88,7 @@ int DD4hep::DDDB::DDDBFileReader::getObject(const std::string& system_id, return 1; } } + ::close(fid); } return 0; } diff --git a/DDG4/src/Geant4Random.cpp b/DDG4/src/Geant4Random.cpp index 9e48e44b545890e9ad189d8b145fe01d30250255..040f9d002f3f5f75bab4ff118cdb9aa76787a9b4 100644 --- a/DDG4/src/Geant4Random.cpp +++ b/DDG4/src/Geant4Random.cpp @@ -251,7 +251,7 @@ void Geant4Random::showStatus() const { if ( gRandom != m_rootRandom ) { printP2(" Local TRandom: 0x%p gRandom: 0x%p",m_rootRandom,gRandom); } - else if ( !m_engine ) { + if ( 0 == m_engine ) { error(" Geant4Random instance has not engine attached!"); return; } diff --git a/DDG4/tpython/DDPython.cpp b/DDG4/tpython/DDPython.cpp index 980e06371727c9fe66ad49b2147a5fd14041b786..db7bf812b0e41f7a6f9aaa9172b8d644b77b2fcb 100644 --- a/DDG4/tpython/DDPython.cpp +++ b/DDG4/tpython/DDPython.cpp @@ -100,7 +100,7 @@ namespace { } } -DDPython::GILState::GILState(int) { +DDPython::GILState::GILState(int) : state(0) { if ( ::Py_IsInitialized() ) { PyGILState_STATE st = (PyGILState_STATE)::PyGILState_Ensure(); state = (int)st;