From db3155a6d46028f3449312f912f465e6e6df7a90 Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Fri, 11 Oct 2019 14:53:45 +0200 Subject: [PATCH] TPTools: Fix cppcheck warnings. Prefer preincrement to postincrement for iterators. --- Database/TPTools/TPTools/TPConverter.icc | 9 +++++---- Database/TPTools/src/AthenaConverterTLPExtension.cxx | 10 +++++----- Database/TPTools/src/TopLevelTPCnvBase.cxx | 6 +++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Database/TPTools/TPTools/TPConverter.icc b/Database/TPTools/TPTools/TPConverter.icc index 564a6be645f..14579105633 100644 --- a/Database/TPTools/TPTools/TPConverter.icc +++ b/Database/TPTools/TPTools/TPConverter.icc @@ -46,6 +46,7 @@ toPersistent_impl( const TRANS *trans, MsgStream &log ) } // make a new space in the storage vector size_t size = m_pStorage->size(); + // cppcheck-suppress uninitvar m_pStorage->resize( size+1 ); if( m_recursive ) { @@ -217,7 +218,7 @@ void TPCnvStdVector<TRANS, PERS, CONV>::persToTrans(const PERS* persVect, typename TRANS::iterator it = transVect->begin(); while(i) { element_cnv.persToTrans( &(*pit), &(*it), log ); - it++; pit++; i--; + ++it; ++pit; --i; } } @@ -250,7 +251,7 @@ void TPCnvStdVectorConst<TRANS, PERS, CONV>::persToTrans(const PERS* persVect, typename TRANS::iterator it = transVect->begin(); while(i) { element_cnv.persToTrans( &(*pit), &(*it), log ); - it++; pit++; i--; + ++it; ++pit; --i; } } @@ -384,7 +385,7 @@ void TPCnvIDCont<TRANS, PERS, CONV>::transToPers(const TRANS* transCont, typename TRANS::const_iterator it_Coll = transCont->begin(); typename TRANS::const_iterator it_CollEnd = transCont->end(); int entries; - for (entries = 0; it_Coll != it_CollEnd; ++entries, it_Coll++) { + for (entries = 0; it_Coll != it_CollEnd; ++entries, ++it_Coll) { persCont->resize(entries + 1); element_cnv.transToPers(&(**it_Coll), &(*persCont)[entries], log); } @@ -426,7 +427,7 @@ void TPCnvIDContFromIdentifier<TRANS, PERS, CONV>::transToPers(const TRANS* tran typename TRANS::const_iterator it_Coll = transCont->begin(); typename TRANS::const_iterator it_CollEnd = transCont->end(); int entries; - for (entries = 0; it_Coll != it_CollEnd; ++entries, it_Coll++) { + for (entries = 0; it_Coll != it_CollEnd; ++entries, ++it_Coll) { persCont->resize(entries + 1); element_cnv.transToPers(&(**it_Coll), &(*persCont)[entries], log); } diff --git a/Database/TPTools/src/AthenaConverterTLPExtension.cxx b/Database/TPTools/src/AthenaConverterTLPExtension.cxx index 75e1be5adf6..dbb27182fad 100644 --- a/Database/TPTools/src/AthenaConverterTLPExtension.cxx +++ b/Database/TPTools/src/AthenaConverterTLPExtension.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ @@ -76,7 +76,7 @@ void AthenaConverterTLPExtension::usingTPCnvForReading( TopLevelTPCnvBase &baseT // copy clones of all extending converters to a new converter map for( extCnvMap_t::const_iterator cnvI = m_extendingConverters.begin(); - cnvI != m_extendingConverters.end(); cnvI++ ) { + cnvI != m_extendingConverters.end(); ++cnvI ) { AthenaConverterTLPExtension *cloned_converter = cnvI->second->clone(); if( !cloned_converter ) { // basically panicking, this is not a runtime exception but an incomplete converter implementation @@ -115,7 +115,7 @@ void AthenaConverterTLPExtension::readExtendingObjects( void *baseObj ) extendingConverters = extCnvMapIter->second; } // load the remaining "pieces" of this object - for( TPCnvTokenList_p1::const_iterator it = tokens->begin(); it != tokens->end(); it++ ) { + for( TPCnvTokenList_p1::const_iterator it = tokens->begin(); it != tokens->end(); ++it ) { if( it->token().size() < 36 ) { ostringstream err; err << "Corrupted Token in the list of extensions. Token='" << it->token() << "'" @@ -148,7 +148,7 @@ void AthenaConverterTLPExtension::readExtendingObjects( void *baseObj ) void AthenaConverterTLPExtension::deletePersistentObjects() { for( extCnvMap_t::const_iterator cnv = m_extendingConverters.begin(); - cnv != m_extendingConverters.end(); cnv++ ) { + cnv != m_extendingConverters.end(); ++cnv ) { cnv->second->deletePersistentObjects(); } for( size_t c = 0; c < m_clonedExtendingCnvs.size(); c++ ) @@ -167,7 +167,7 @@ AthenaConverterTLPExtension::~AthenaConverterTLPExtension() for( size_t c = 0; c < m_clonedExtendingCnvs.size(); c++ ) delete m_clonedExtendingCnvs[c]; for( extCnvMapMap_t::const_iterator mmiter = m_extCnvMapMap.begin(); - mmiter != m_extCnvMapMap.end(); mmiter++ ) { + mmiter != m_extCnvMapMap.end(); ++mmiter ) { delete mmiter->second; } diff --git a/Database/TPTools/src/TopLevelTPCnvBase.cxx b/Database/TPTools/src/TopLevelTPCnvBase.cxx index 16e2639ccb3..66b45eed3bc 100644 --- a/Database/TPTools/src/TopLevelTPCnvBase.cxx +++ b/Database/TPTools/src/TopLevelTPCnvBase.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ @@ -61,7 +61,7 @@ void TopLevelTPCnvBase::addTPConvertersTo( TopLevelTPCnvBase *cnv ) { // loop over all registered converters for( convIdMap_t::const_iterator itr = m_convIdMap.begin(); - itr != m_convIdMap.end(); itr++ ) { + itr != m_convIdMap.end(); ++itr ) { // check if the converter is in the list of R/W converters if( m_converters.findConverter( itr->second->transientTInfo() ) == itr->second ) { // this is a R/W converter, add it for writing too @@ -83,7 +83,7 @@ void TopLevelTPCnvBase::addTPConvertersForReadingTo( TopLevelTPCnvBase *cnv ) } // copy all TP converters to another topLevel conveter for( convIdMap_t::const_iterator itr = m_convIdMap.begin(); - itr != m_convIdMap.end(); itr++ ) { + itr != m_convIdMap.end(); ++itr ) { cnv->addExtTPConverterForReading( itr->second ); } // prevent attempts to add the same converters again -- GitLab