Skip to content
Snippets Groups Projects
Commit 2b39f35f authored by Gerhard Raven's avatar Gerhard Raven
Browse files

fix -Wnull-dereference-warnings

parent 0c9ceae8
No related branches found
No related tags found
1 merge request!808add -Wnon-virtual-dtor and fix corresponding warning
......@@ -113,7 +113,7 @@ void RecordDataSvc::handle( const Incident& incident )
void RecordDataSvc::loadRecords( IRegistry* pObj )
{
if ( !pObj ) {
error() << "Failed to load records object: " << pObj->identifier() << endmsg;
error() << "Failed to load records object" << endmsg;
} else {
vector<IRegistry*> leaves;
DataObject* p = nullptr;
......
......@@ -252,7 +252,10 @@ StatusCode AlgResourcePool::decodeTopAlgs()
// Now we unroll it ----
for ( auto& algoSmartIF : m_topAlgList ) {
Algorithm* algorithm = dynamic_cast<Algorithm*>( algoSmartIF.get() );
if ( !algorithm ) fatal() << "Conversion from IAlgorithm to Algorithm failed" << endmsg;
if ( !algorithm ) {
fatal() << "Conversion from IAlgorithm to Algorithm failed" << endmsg;
return StatusCode::FAILURE;
}
sc = flattenSequencer( algorithm, m_flatUniqueAlgList );
}
// stupid O(N^2) unique-ification..
......@@ -283,7 +286,10 @@ StatusCode AlgResourcePool::decodeTopAlgs()
verbose() << "Treating resource management and clones of " << item_name << endmsg;
Algorithm* algo = dynamic_cast<Algorithm*>( ialgoSmartIF.get() );
if ( !algo ) fatal() << "Conversion from IAlgorithm to Algorithm failed" << endmsg;
if ( !algo ) {
fatal() << "Conversion from IAlgorithm to Algorithm failed" << endmsg;
return StatusCode::FAILURE;
}
const std::string& item_type = algo->type();
size_t algo_id = hash_function( item_name );
......
......@@ -150,6 +150,7 @@ StatusCode AvalancheSchedulerSvc::initialize()
Algorithm* algoPtr = dynamic_cast<Algorithm*>( ialgoPtr );
if ( !algoPtr ) {
fatal() << "Could not convert IAlgorithm into Algorithm: this will result in a crash." << endmsg;
return StatusCode::FAILURE;
}
for ( auto id : algoPtr->outputDataObjs() ) {
auto r = globalOutp.insert( id );
......
......@@ -849,19 +849,13 @@ public:
samples[index] += value;
return;
}
bool get_max( char* index, unsigned int* value )
bool get_max( char* index, unsigned int& value )
{
if ( samples.empty() ) return false;
unsigned int cur_max = 0;
std::map<std::string, unsigned int>::iterator max_pos;
for ( std::map<std::string, unsigned int>::iterator it = samples.begin(); it != samples.end(); ++it ) {
if ( it->second > cur_max ) {
cur_max = it->second;
max_pos = it;
}
}
auto max_pos = std::max_element( samples.begin(), samples.end(),
[]( const auto& lhs, const auto& rhs ) { return lhs.second < rhs.second; } );
if ( max_pos == samples.end() ) return false;
strcpy( index, ( max_pos->first ).c_str() );
*value = max_pos->second;
value = max_pos->second;
samples.erase( max_pos );
return true;
}
......@@ -1185,7 +1179,7 @@ void put_S_module( S_module* cur_module, const char* dir )
char index[MAX_SAMPLE_INDEX_LENGTH];
bzero( index, MAX_SAMPLE_INDEX_LENGTH );
unsigned int value;
bool res = cur_module->get_max( index, &value );
bool res = cur_module->get_max( index, value );
if ( !res ) break;
char* sym_end = strchr( index, '%' );
if ( sym_end == NULL ) // error
......
......@@ -21,26 +21,32 @@
namespace
{
template <class T>
static long upper( const INTupleItem* item )
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnull-dereference"
const NTuple::_Data<T>* it = dynamic_cast<const NTuple::_Data<T>*>( item );
assert( it != nullptr );
return it->range().upper();
#pragma GCC diagnostic pop
}
template <class TYP>
static StatusCode createItem( MsgStream& log, INTuple* tuple, INTupleItem* src, const TYP& null )
{
NTuple::_Data<TYP>* source = dynamic_cast<NTuple::_Data<TYP>*>( src );
TYP low = source->range().lower();
TYP high = source->range().upper();
long hasIdx = source->hasIndex();
long ndim = source->ndim();
const std::string& name = source->name();
std::string idxName;
long dim[4], idxLen = 0;
long dim1 = 1, dim2 = 1;
INTupleItem* it = nullptr;
if ( !source ) return StatusCode::FAILURE;
TYP low = source->range().lower();
TYP high = source->range().upper();
long hasIdx = source->hasIndex();
long ndim = source->ndim();
const std::string& name = source->name();
std::string idxName;
long dim[4], idxLen = 0;
long dim1 = 1, dim2 = 1;
INTupleItem* it = nullptr;
for ( int i = 0; i < ndim; i++ ) dim[i] = source->dim( i );
/// Type information of the item
if ( hasIdx ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment