From dbcb045d98a26e437dbb4a15785b6b5ad8e2e34d Mon Sep 17 00:00:00 2001
From: scott snyder <sss@karma>
Date: Wed, 7 Oct 2020 11:27:05 -0400
Subject: [PATCH] FileCatalog: Fix cppcheck warnings.

 - Prefer pre-increment (or range-for) to postincrement.
 - Prefer using an initialization list to initializing membesr
   in a ctor body.
---
 .../FileCatalog/FileCatalog/IFileCatalog.h    | 52 +++++++++----------
 Database/APR/FileCatalog/src/CommandLine.cpp  |  4 +-
 Database/APR/FileCatalog/src/IFileCatalog.cpp | 22 ++++----
 3 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/Database/APR/FileCatalog/FileCatalog/IFileCatalog.h b/Database/APR/FileCatalog/FileCatalog/IFileCatalog.h
index 80bf9bd3676..7f2a97d2b72 100644
--- a/Database/APR/FileCatalog/FileCatalog/IFileCatalog.h
+++ b/Database/APR/FileCatalog/FileCatalog/IFileCatalog.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef APR_IFILECATALOG_H
@@ -39,29 +39,29 @@ namespace pool {
      void connect() { /* not doing anything in Gaudi FC */ }
      void disconnect() { /* not doing anything in Gaudi FC */ }
      /// Get the connect string
-     const std::string& connectInfo() const { return _fc->connectInfo(); }
+     const std::string& connectInfo() const { return m_fc->connectInfo(); }
        
      /// redirect to init() for Gaudi FC
      void start() { init(); }
      /// Parse the DOM tree of the XML catalog
-     void init() { _fc->init(); }
+     void init() { m_fc->init(); }
      /// Save catalog to file
-     void commit() { _fc->commit(); }
+     void commit() { m_fc->commit(); }
      /// Save catalog to file
-     void rollback() { _fc->rollback(); }
+     void rollback() { m_fc->rollback(); }
      /// Check if the catalog is read-only
-     bool readOnly() const { return _fc->readOnly(); }
+     bool readOnly() const { return m_fc->readOnly(); }
      /// Check if the catalog should be updated
-     bool dirty() const  { return _fc->dirty(); }
+     bool dirty() const  { return m_fc->dirty(); }
 
      /// Get all FIDs 
-     void getFIDs( Strings& fids ) const { _fc->getFID(fids); }
+     void getFIDs( Strings& fids ) const { m_fc->getFID(fids); }
      
      /// Get all logical names for a given FID. Return pairs <LFN,FID>
-     void getLFNs( const std::string& fid, Files& files ) const { _fc->getLFN(fid, files); }
+     void getLFNs( const std::string& fid, Files& files ) const { m_fc->getLFN(fid, files); }
 
      /// Dump all PFNames of the catalog and their attributes associate to the FileID
-     void getPFNs( const std::string& fid, Files& files ) const { _fc->getPFN(fid, files); }
+     void getPFNs( const std::string& fid, Files& files ) const { m_fc->getPFN(fid, files); }
 
      /// Get the first PFN + filetype for the given FID
      void getFirstPFN( const std::string& fid, std::string& pfn, std::string& tech ) const;
@@ -70,32 +70,32 @@ namespace pool {
      void lookupFileByPFN( const std::string& pfn, std::string& fid, std::string& tech ) const;
 
      /// Return the status of a PFName
-     bool existsPFN( const std::string& pfn ) const { return _fc->existsPFN(pfn); }
+     bool existsPFN( const std::string& pfn ) const { return m_fc->existsPFN(pfn); }
 
      /// Lookup file identifier by physical file name
-     std::string lookupPFN( const std::string& pfn ) const { return _fc->lookupPFN(pfn); }
+     std::string lookupPFN( const std::string& pfn ) const { return m_fc->lookupPFN(pfn); }
 
      /// Return the status of a LFName
      //    bool existsLFN( const std::string& lfn ) const = 0;
 
      /// Lookup file identified by logical file name
      void lookupFileByLFN( const std::string& lfn, std::string& fid ) const { fid = lookupLFN(lfn); }
-     std::string lookupLFN( const std::string& lfn ) const { return _fc->lookupLFN(lfn); }
+     std::string lookupLFN( const std::string& lfn ) const { return m_fc->lookupLFN(lfn); }
 
      /// Return the status of a FileID
      //    bool existsFID( const std::string& fid ) const = 0;
 
      /// Delete FileID Node from the catalog
-     void deleteFID( const std::string& FileID ) { _fc->deleteFID(FileID); }
+     void deleteFID( const std::string& FileID ) { m_fc->deleteFID(FileID); }
 
      /// Delete PFN from the catalog (delete entire FID entry if it was the last PFN)
-     void deletePFN( const std::string& pfn ) { _fc->deletePFN(pfn); }
+     void deletePFN( const std::string& pfn ) { m_fc->deletePFN(pfn); }
 
      /// Register PFN, assign new FID if not given
      void registerPFN( const std::string& pfn, const std::string& ftype, std::string& fid );
 
      /// Rename PFN
-     void renamePFN( const std::string& pfn, const std::string& newpfn ) { _fc->renamePFN(pfn, newpfn); }
+     void renamePFN( const std::string& pfn, const std::string& newpfn ) { m_fc->renamePFN(pfn, newpfn); }
 
      /// adding replica to an existing PFN
      void addReplicaPFN( const std::string& pfn, const std::string& replica_pfn );
@@ -107,7 +107,7 @@ namespace pool {
 
      /// Create a Node for a FileID and DOM Node of the LFN with all the attributes
      // NOTE!  this method requires FID! (and not PFN)
-     void registerLFN( const std::string& fid, const std::string& lfn ) const { _fc->registerLFN(fid, lfn ); }
+     void registerLFN( const std::string& fid, const std::string& lfn ) const { m_fc->registerLFN(fid, lfn ); }
 
 
      // ------------------------- Catalog Manager interface
@@ -117,28 +117,28 @@ namespace pool {
      void addCatalog( const std::string& connect );
 
      /// Add new catalog identified by reference to the existing ones
-     //void addCatalog(  Gaudi::IFileCatalog* cat )  { _mgr->addCatalog(cat); }
+     //void addCatalog(  Gaudi::IFileCatalog* cat )  { m_mgr->addCatalog(cat); }
 
      /// Remove catalog identified by name from the existing ones. * or '' removes all
-     void removeCatalog( const std::string& connect )  { _mgr->removeCatalog(connect); }
+     void removeCatalog( const std::string& connect )  { m_mgr->removeCatalog(connect); }
      
      /// Remove catalog identified by reference from the existing ones
-     //void removeCatalog( const  Gaudi::IFileCatalog* cat )  { _mgr->removeCatalog(cat); }
+     //void removeCatalog( const  Gaudi::IFileCatalog* cat )  { m_mgr->removeCatalog(cat); }
      /// Access catalog container
-     Catalogs& catalogs() { return _mgr->catalogs(); }
+     Catalogs& catalogs() { return m_mgr->catalogs(); }
      /// Access catalog container (CONST)
-     const Catalogs& catalogs() const  { return _mgr->catalogs(); }
+     const Catalogs& catalogs() const  { return m_mgr->catalogs(); }
      /// Access to the (first) writable file catalog
-     //Gaudi::IFileCatalog* writeCatalog( const std::string& fid = "" ) const  { return _mgr->writeCatalog(fid); }
+     //Gaudi::IFileCatalog* writeCatalog( const std::string& fid = "" ) const  { return m_mgr->writeCatalog(fid); }
      /// Define the writable catalog identified by reference
-     //void setWriteCatalog(  Gaudi::IFileCatalog* cat )  { _mgr->setWriteCatalog(cat); }
+     //void setWriteCatalog(  Gaudi::IFileCatalog* cat )  { m_mgr->setWriteCatalog(cat); }
      /// Define the writable catalog identified by name
      void setWriteCatalog( const std::string& connect );
      
 
   protected:
-     SmartIF<Gaudi::IFileCatalogMgr>    _mgr;
-     SmartIF<Gaudi::IFileCatalog>       _fc;
+     SmartIF<Gaudi::IFileCatalogMgr>    m_mgr;
+     SmartIF<Gaudi::IFileCatalog>       m_fc;
    };
 
 }
diff --git a/Database/APR/FileCatalog/src/CommandLine.cpp b/Database/APR/FileCatalog/src/CommandLine.cpp
index 30db9d13cba..770b71d1457 100755
--- a/Database/APR/FileCatalog/src/CommandLine.cpp
+++ b/Database/APR/FileCatalog/src/CommandLine.cpp
@@ -4,7 +4,7 @@
 *  CommandLine.cpp
 *  Created by John F. Hubbard, on Sat Jul 29 2000, 19:01:05 PST
 *
-*  Copyright (c) 2000, ATD Azad Technology Development Corporation
+*  Copyright (c) 2000, 2020, ATD Azad Technology Development Corporation
 *
 *            The Reliable Software Outsource Resource
 *        You hire us, we do it for you, and we do it right.
@@ -232,7 +232,7 @@ pool::CommandLine::DumpDiagnostics() const
   cout << endl << "Parameter name" << "\t\t\tValue" << endl;
   cout << "-------------------------------------" << endl;
   for(ARGMAPTYPE::const_iterator it = mArgMap.begin();
-    it != mArgMap.end(); it++)
+    it != mArgMap.end(); ++it)
   {
     cout << it->first << ":\t\t\t\t" << it->second << endl;
   }
diff --git a/Database/APR/FileCatalog/src/IFileCatalog.cpp b/Database/APR/FileCatalog/src/IFileCatalog.cpp
index 3334819562f..73678f259d9 100644
--- a/Database/APR/FileCatalog/src/IFileCatalog.cpp
+++ b/Database/APR/FileCatalog/src/IFileCatalog.cpp
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "GaudiUtils/IFileCatalog.h"
@@ -22,10 +22,10 @@
 using namespace pool;
 
 pool::IFileCatalog::IFileCatalog()
-  : AthMessaging( Gaudi::svcLocator()->service<IMessageSvc>("MessageSvc").get(), "APRFileCatalog" )
+  : AthMessaging( Gaudi::svcLocator()->service<IMessageSvc>("MessageSvc").get(), "APRFileCatalog" ),
+    m_mgr (Gaudi::svcLocator()->service<Gaudi::IFileCatalogMgr>( "Gaudi::MultiFileCatalog" )),
+    m_fc (m_mgr)
 {
-   _mgr = Gaudi::svcLocator()->service<Gaudi::IFileCatalogMgr>( "Gaudi::MultiFileCatalog" );
-   _fc = _mgr;
    // set the output level of this service
    setLevel( SystemTools::GetOutputLvl() );
    // set the output level of the XMLCatalog component - works only if the Gaudi AppMgr was initialized
@@ -84,7 +84,7 @@ registerPFN( const std::string& pfn, const std::string& ftype, std::string& fid
    }
    if( fid.empty() ) fid = createFID();
    ATH_MSG_DEBUG("Registering PFN=" << pfn << " of type=" << ftype << " GUID=" << fid);
-   _fc->registerPFN(fid, pfn, ftype);
+   m_fc->registerPFN(fid, pfn, ftype);
 }
 
 
@@ -92,7 +92,7 @@ registerPFN( const std::string& pfn, const std::string& ftype, std::string& fid
 void pool::IFileCatalog::
 addReplicaPFN( const std::string& pfn, const std::string& replica_pfn )
 { 
-   std::string fid = _fc->lookupPFN(pfn);
+   std::string fid = m_fc->lookupPFN(pfn);
    if( fid.empty() )
       throw pool::Exception(std::string("PFN '") + pfn + "' not found", "addReplicaPFN", "FileCatalog");
    // find the filetype for the PFN being replicated
@@ -100,7 +100,7 @@ addReplicaPFN( const std::string& pfn, const std::string& replica_pfn )
    getPFNs( fid, pfns );
    for( const auto& pfns_entry: pfns ) {
       if( pfns_entry.first == pfn ) {
-         _fc->registerPFN(fid, replica_pfn, pfns_entry.second);
+         m_fc->registerPFN(fid, replica_pfn, pfns_entry.second);
          return;
       }
    }
@@ -112,7 +112,7 @@ addReplicaFID( const std::string& fid, const std::string& replica_pfn, const std
 { 
    if( fid.empty() )
       throw pool::Exception(std::string("FID not specified"), "addReplicaFID", "FileCatalog");
-   _fc->registerPFN(fid, replica_pfn, replica_tech);
+   m_fc->registerPFN(fid, replica_pfn, replica_tech);
 }
 
 
@@ -124,7 +124,7 @@ void pool::IFileCatalog::addCatalog( const std::string& connect )
 {
    URIParser p(connect);
    p.parse();
-   Catalogs& cats = _mgr->catalogs();     
+   Catalogs& cats = m_mgr->catalogs();     
    auto i = std::find_if( cats.begin(), cats.end(),
                           [&]( const Gaudi::IFileCatalog* f )
                           { return p.url() == f->connectInfo(); } );
@@ -136,7 +136,7 @@ void pool::IFileCatalog::addCatalog( const std::string& connect )
          fullconnectstr = "xmlcatalog_" + connect;
       }
       ATH_MSG_DEBUG("addCatalog(\"" << fullconnectstr << "\")" );
-      _mgr->addCatalog( fullconnectstr );
+      m_mgr->addCatalog( fullconnectstr );
    }
 }
 
@@ -146,7 +146,7 @@ void pool::IFileCatalog::setWriteCatalog( const std::string& connect )
    URIParser p(connect);
    p.parse();
    addCatalog( connect );
-   _mgr->setWriteCatalog( _mgr->findCatalog( p.url(), true ) );
+   m_mgr->setWriteCatalog( m_mgr->findCatalog( p.url(), true ) );
 }
      
 
-- 
GitLab