From a993263c7ef23c4a386d3f25b7ad6b90e00d7060 Mon Sep 17 00:00:00 2001 From: Frank Winklmeier Date: Mon, 20 Nov 2017 17:53:30 +0100 Subject: [PATCH] Remove implicit StatusCode bool/long conversions Replace code that relies on implicit StatusCode bool/long conversions. --- GaudiAud/src/AlgErrorAuditor.cpp | 4 ++-- GaudiCoreSvc/src/ApplicationMgr/DLLClassManager.cpp | 2 +- GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp | 3 ++- GaudiGSL/src/Components/EqSolver.cpp | 2 +- GaudiKernel/GaudiKernel/ParsersFactory.h | 5 +++-- GaudiKernel/src/Lib/Bootstrap.cpp | 5 ++--- GaudiKernel/src/Lib/KeyedObjectManager.cpp | 13 ++++++++----- GaudiKernel/src/Lib/MsgStream.cpp | 2 +- GaudiKernel/src/Lib/ParsersStandardMisc5.cpp | 3 ++- GaudiKernel/src/Lib/ParsersVct.cpp | 2 +- GaudiProfiling/src/component/PerfMonAuditor.cpp | 2 +- GaudiPython/src/Lib/Algorithm.cpp | 4 ++-- 12 files changed, 26 insertions(+), 21 deletions(-) diff --git a/GaudiAud/src/AlgErrorAuditor.cpp b/GaudiAud/src/AlgErrorAuditor.cpp index 5af0a162f6..8b1bb93134 100644 --- a/GaudiAud/src/AlgErrorAuditor.cpp +++ b/GaudiAud/src/AlgErrorAuditor.cpp @@ -39,7 +39,7 @@ void AlgErrorAuditor::afterExecute( INamedInterface* alg, const StatusCode& sc ) fail = true; if ( m_throw && !m_abort ) { - throw GaudiException( os.str(), "AlgErrorAuditor", 0 ); + throw GaudiException( os.str(), "AlgErrorAuditor", StatusCode::FAILURE ); } } @@ -56,7 +56,7 @@ void AlgErrorAuditor::afterExecute( INamedInterface* alg, const StatusCode& sc ) fail = true; if ( m_throw && !m_abort ) { - throw GaudiException( os.str(), "AlgErrorAuditor", 0 ); + throw GaudiException( os.str(), "AlgErrorAuditor", StatusCode::FAILURE ); } } diff --git a/GaudiCoreSvc/src/ApplicationMgr/DLLClassManager.cpp b/GaudiCoreSvc/src/ApplicationMgr/DLLClassManager.cpp index f8e668dfcd..9f8712cabd 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/DLLClassManager.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/DLLClassManager.cpp @@ -39,7 +39,7 @@ StatusCode DLLClassManager::loadModule( const std::string& module, bool fireInci void* libHandle = nullptr; StatusCode status = StatusCode::FAILURE; try { - status = System::loadDynamicLib( module, &libHandle ); + status = System::loadDynamicLib( module, &libHandle ) ? StatusCode::SUCCESS : StatusCode::FAILURE; } catch ( const std::exception& excpt ) { if ( m_msgsvc ) { log << MSG::ERROR << "Exception whilst loading " << module << " : " << excpt.what() << endmsg; diff --git a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp index b5ddedbf95..9b3a54467d 100644 --- a/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp +++ b/GaudiCoreSvc/src/JobOptionsSvc/JobOptionsSvc.cpp @@ -123,7 +123,8 @@ StatusCode JobOptionsSvc::readOptions( const std::string& file, const std::strin gp::Units units; gp::PragmaOptions pragma; gp::Node ast; - StatusCode sc = gp::ReadOptions( file, path, &messages, &catalog, &units, &pragma, &ast ); + StatusCode sc = gp::ReadOptions( file, path, &messages, &catalog, &units, &pragma, &ast ) ? StatusCode::SUCCESS + : StatusCode::FAILURE; // -------------------------------------------------------------------------- if ( sc.isSuccess() ) { diff --git a/GaudiGSL/src/Components/EqSolver.cpp b/GaudiGSL/src/Components/EqSolver.cpp index b7224e69fd..1a55d0434d 100644 --- a/GaudiGSL/src/Components/EqSolver.cpp +++ b/GaudiGSL/src/Components/EqSolver.cpp @@ -186,7 +186,7 @@ StatusCode EqSolver::solver( const Equations& funcs, Arg& arg ) const return Error( "Method finished with '" + std::string( gsl_strerror( status ) ) + "' error" ); } - return GSL_SUCCESS; + return StatusCode( GSL_SUCCESS ); } //============================================================================= diff --git a/GaudiKernel/GaudiKernel/ParsersFactory.h b/GaudiKernel/GaudiKernel/ParsersFactory.h index 9621c5b4d3..8c29d478c3 100644 --- a/GaudiKernel/GaudiKernel/ParsersFactory.h +++ b/GaudiKernel/GaudiKernel/ParsersFactory.h @@ -35,7 +35,8 @@ namespace Gaudi Skipper skipper; typename Grammar_::Grammar g; IteratorT iter = input.begin(), end = input.end(); - return qi::phrase_parse( iter, end, g, skipper, result ) && ( iter == end ); + return ( qi::phrase_parse( iter, end, g, skipper, result ) && ( iter == end ) ? StatusCode::SUCCESS + : StatusCode::FAILURE ); } //========================================================================= template <> @@ -48,7 +49,7 @@ namespace Gaudi result = input; } //@attention always - return true; + return StatusCode::SUCCESS; } //========================================================================= template diff --git a/GaudiKernel/src/Lib/Bootstrap.cpp b/GaudiKernel/src/Lib/Bootstrap.cpp index bc5a8b23ef..1cc622e9cc 100644 --- a/GaudiKernel/src/Lib/Bootstrap.cpp +++ b/GaudiKernel/src/Lib/Bootstrap.cpp @@ -151,9 +151,8 @@ IInterface* Gaudi::createInstance( const std::string& name, const std::string& f IAlgorithm* ia = Algorithm::Factory::create( factname, name, nullptr ); if ( ia ) return ia; - void* libHandle = nullptr; - StatusCode status = System::loadDynamicLib( dllname, &libHandle ); - if ( status.isSuccess() ) { + void* libHandle = nullptr; + if ( System::loadDynamicLib( dllname, &libHandle ) ) { ii = ObjFactory::create( factname, nullptr ); if ( ii ) return ii; is = Service::Factory::create( factname, name, nullptr ); diff --git a/GaudiKernel/src/Lib/KeyedObjectManager.cpp b/GaudiKernel/src/Lib/KeyedObjectManager.cpp index b930187844..6dc3e92f5a 100644 --- a/GaudiKernel/src/Lib/KeyedObjectManager.cpp +++ b/GaudiKernel/src/Lib/KeyedObjectManager.cpp @@ -73,28 +73,31 @@ namespace Containers } void Containers::cannotAssignObjectKey() { - throw GaudiException( "Cannot assign key to keyed object! Object already has a key.", "KeyedObject", 0 ); + throw GaudiException( "Cannot assign key to keyed object! Object already has a key.", "KeyedObject", + StatusCode::FAILURE ); } void Containers::cannotInsertToContainer() { - throw GaudiException( "Cannot insert element to Keyed Container!", "KeyedContainer", 0 ); + throw GaudiException( "Cannot insert element to Keyed Container!", "KeyedContainer", StatusCode::FAILURE ); } void Containers::containerIsInconsistent() { - throw GaudiException( "Keyed Container structures are inconsistent - severe problem!", "KeyedContainer", 0 ); + throw GaudiException( "Keyed Container structures are inconsistent - severe problem!", "KeyedContainer", + StatusCode::FAILURE ); } void Containers::invalidContainerOperation() { - throw GaudiException( "Keyed Container cannot satisfy request - severe problem!", "KeyedContainer", 0 ); + throw GaudiException( "Keyed Container cannot satisfy request - severe problem!", "KeyedContainer", + StatusCode::FAILURE ); } template Containers::KeyedObjectManager::KeyedObjectManager() : m_seq( nullptr ), m_direct( 0 ) { if ( sizeof( typename T::map_type ) > sizeof( m_setup.buffer ) ) { - throw GaudiException( "Basic STL contaier sizes are incompatible", "KeyedContainer", 0 ); + throw GaudiException( "Basic STL contaier sizes are incompatible", "KeyedContainer", StatusCode::FAILURE ); } m_setup.s = ::new ( m_setup.buffer + sizeof( m_setup.s ) ) T(); m_keyCtxt = -1; diff --git a/GaudiKernel/src/Lib/MsgStream.cpp b/GaudiKernel/src/Lib/MsgStream.cpp index 3d5d5cb724..db5fb90304 100644 --- a/GaudiKernel/src/Lib/MsgStream.cpp +++ b/GaudiKernel/src/Lib/MsgStream.cpp @@ -125,7 +125,7 @@ std::string format( const char* fmt, ... ) va_start( arguments, fmt ); if ( vsnprintf( buffer, buffsize, fmt, arguments ) >= buffsize ) throw GaudiException( "Insufficient buffer size (" + std::to_string( buffsize ) + ") when formatting message", - "MsgStream", 0 ); + "MsgStream", StatusCode::FAILURE ); va_end( arguments ); return std::string( buffer ); } diff --git a/GaudiKernel/src/Lib/ParsersStandardMisc5.cpp b/GaudiKernel/src/Lib/ParsersStandardMisc5.cpp index 75cb04e9bc..7683ca47f1 100644 --- a/GaudiKernel/src/Lib/ParsersStandardMisc5.cpp +++ b/GaudiKernel/src/Lib/ParsersStandardMisc5.cpp @@ -15,8 +15,9 @@ StatusCode Gaudi::Parsers::parse( std::string& name, std::string& value, const s if ( parse_result ) { name = result.first; value = result.second; + return StatusCode::SUCCESS; } - return parse_result; + return StatusCode::FAILURE; } StatusCode Gaudi::Parsers::parse( std::map>& result, const std::string& input ) diff --git a/GaudiKernel/src/Lib/ParsersVct.cpp b/GaudiKernel/src/Lib/ParsersVct.cpp index 6ad71aa774..8301c559c2 100644 --- a/GaudiKernel/src/Lib/ParsersVct.cpp +++ b/GaudiKernel/src/Lib/ParsersVct.cpp @@ -44,7 +44,7 @@ namespace Gaudi return StatusCode::SUCCESS; } //@attention always - return true; + return StatusCode::SUCCESS; } // ========================================================================== diff --git a/GaudiProfiling/src/component/PerfMonAuditor.cpp b/GaudiProfiling/src/component/PerfMonAuditor.cpp index ce0974a3cb..5799a3b841 100644 --- a/GaudiProfiling/src/component/PerfMonAuditor.cpp +++ b/GaudiProfiling/src/component/PerfMonAuditor.cpp @@ -565,7 +565,7 @@ StatusCode PerfMonAuditor::initialize() { if ( !m_pfm.loaded ) { error() << "pfm library could not be loaded" << endmsg; - return false; + return StatusCode::FAILURE; } info() << "Initializing..." << endmsg; diff --git a/GaudiPython/src/Lib/Algorithm.cpp b/GaudiPython/src/Lib/Algorithm.cpp index 4509e3dbcb..2c5e6b500c 100644 --- a/GaudiPython/src/Lib/Algorithm.cpp +++ b/GaudiPython/src/Lib/Algorithm.cpp @@ -43,7 +43,7 @@ StatusCode GaudiPython::call_python_method( PyObject* self, const char* method ) } // RETURN if ( PyInt_Check( r ) ) { - sc = PyInt_AS_LONG( r ); + sc = StatusCode( PyInt_AS_LONG( r ) ); Py_DECREF( r ); return sc; } // RETURN @@ -55,7 +55,7 @@ StatusCode GaudiPython::call_python_method( PyObject* self, const char* method ) if ( !c ) { PyErr_Print(); } else if ( PyLong_Check( c ) ) { - sc = PyLong_AsLong( c ); + sc = StatusCode( PyLong_AsLong( c ) ); } else { std::string msg( " call_python_method unexpected type from '" ); msg += method; -- GitLab