From c336f4fb0cf0a473ddcfd3bfb5f63ddac5f2ae50 Mon Sep 17 00:00:00 2001
From: scott snyder <sss@karma>
Date: Sat, 5 Sep 2020 12:49:19 -0400
Subject: [PATCH] CoraCool: Fix cppcheck warnings.

Pass class instances by const reference, not by value.
---
 Database/CoraCool/CoraCool/CoraCoolDatabase.h | 12 ++++++------
 Database/CoraCool/CoraCool/CoraCoolFolder.h   |  8 ++++----
 Database/CoraCool/src/CoraCoolDatabase.cxx    | 10 +++++-----
 Database/CoraCool/src/CoraCoolFolder.cxx      |  8 ++++----
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/Database/CoraCool/CoraCool/CoraCoolDatabase.h b/Database/CoraCool/CoraCool/CoraCoolDatabase.h
index 044e69bed06..09be51b9bb6 100755
--- a/Database/CoraCool/CoraCool/CoraCoolDatabase.h
+++ b/Database/CoraCool/CoraCool/CoraCoolDatabase.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 CORACOOL_CORACOOLDATABASE_H
@@ -25,7 +25,7 @@ class CoraCoolDatabase {
  public:
   // instantiate a new CoraCoolDatabase instance
   // this should not normally be used - use openDatabase in CoraCoolDatabaseSvc
-  CoraCoolDatabase(const std::string m_dbconn, cool::IDatabasePtr cooldb,
+  CoraCoolDatabase(const std::string& m_dbconn, cool::IDatabasePtr cooldb,
 	       coral::IConnectionService& coralsvc, const bool readonly=false);
 
   // connect to the underlying database, return true if connected
@@ -49,9 +49,9 @@ class CoraCoolDatabase {
      const std::string& coraltable,
      const cool::IRecordSpecification& fkspec,
      const cool::IRecordSpecification& payloadspec,
-     const std::string coralfk,
-     const std::string coralpk,
-     const std::string description="",
+     const std::string& coralfk,
+     const std::string& coralpk,
+     const std::string& description="",
      const cool::FolderVersioning::Mode mode=cool::FolderVersioning::SINGLE_VERSION,
      const bool createParents=false);
 
@@ -68,7 +68,7 @@ class CoraCoolDatabase {
   // parse the COOL folder description to extract the CORAL table name,
   // COOL and CORAL foreign and primary key names
   // returns true if all information extracted, false if syntax problems
-  bool parseFolderDescription(const std::string folderdesc,
+  bool parseFolderDescription(const std::string& folderdesc,
 			      std::string& tablename,
 			      std::string& keycolcool,
 			      std::string& fkeycolcoral,
diff --git a/Database/CoraCool/CoraCool/CoraCoolFolder.h b/Database/CoraCool/CoraCool/CoraCoolFolder.h
index 43074b7fb29..7280728e5a6 100755
--- a/Database/CoraCool/CoraCool/CoraCoolFolder.h
+++ b/Database/CoraCool/CoraCool/CoraCoolFolder.h
@@ -78,7 +78,7 @@ class CoraCoolFolder {
 		   const_iterator begin,
 		   const_iterator end,
 		   const cool::ChannelId& channelId=0,
-		   const std::string tagName="",
+		   const std::string& tagName="",
 		   const bool userTagOnly=false);
 
   // setup storage buffer for bulk insertion via repeated storeObject calls
@@ -95,7 +95,7 @@ class CoraCoolFolder {
 		       const cool::ValidityKey& until,
 		       const coral::Attribute& fkey,
 		       const cool::ChannelId& channelId=0,
-		       const std::string tagName="",
+		       const std::string& tagName="",
 		       const bool userTagOnly=false);
 
   // add a reference to COOL to an existing stored payload object
@@ -104,7 +104,7 @@ class CoraCoolFolder {
 		       const cool::ValidityKey& until,
 		       const int ifkey,
 		       const cool::ChannelId& channelId=0,
-		       const std::string tagName="",
+		       const std::string& tagName="",
 		       const bool userTagOnly=false);
 
   // add more payload AttributeLists to the CORAL payload table
@@ -117,7 +117,7 @@ class CoraCoolFolder {
   // find the one object valid at a given time/channel and tag
   CoraCoolObjectPtr findObject(const cool::ValidityKey& pointInTime,
 			       const cool::ChannelId& channelId=0, 
-			       const std::string tagName="");
+			       const std::string& tagName="");
 
   // return an iterator to a set of objects identified by a point in time
   // and a channel specification (and optionally a tag)
diff --git a/Database/CoraCool/src/CoraCoolDatabase.cxx b/Database/CoraCool/src/CoraCoolDatabase.cxx
index 27bca45fdcd..0cc775483fd 100755
--- a/Database/CoraCool/src/CoraCoolDatabase.cxx
+++ b/Database/CoraCool/src/CoraCoolDatabase.cxx
@@ -34,7 +34,7 @@
 #include "CxxUtils/checker_macros.h"
 
 // constructor with external COOL database reference
-CoraCoolDatabase::CoraCoolDatabase(const std::string dbconn,
+CoraCoolDatabase::CoraCoolDatabase(const std::string& dbconn,
                                    cool::IDatabasePtr cooldb,
                                    coral::IConnectionService& coralsvc,
                                    const bool readonly) :
@@ -193,9 +193,9 @@ CoraCoolFolderPtr CoraCoolDatabase::createFolder(const std::string& coolpath,
      const std::string& coraltable,
      const cool::IRecordSpecification& fkspec,
      const cool::IRecordSpecification& payloadspec,
-     const std::string coralfk,
-     const std::string coralpk,
-     const std::string description,
+     const std::string& coralfk,
+     const std::string& coralpk,
+     const std::string& description,
      const cool::FolderVersioning::Mode mode,
      const bool createParents) {
 
@@ -313,7 +313,7 @@ bool CoraCoolDatabase::existsFolder(const std::string& coolfolder) {
   }
 }
 
-bool CoraCoolDatabase::parseFolderDescription(const std::string folderdesc,
+bool CoraCoolDatabase::parseFolderDescription(const std::string& folderdesc,
 					      std::string& tablename,
 					      std::string& keycolcool,
 					      std::string& fkeycolcoral,
diff --git a/Database/CoraCool/src/CoraCoolFolder.cxx b/Database/CoraCool/src/CoraCoolFolder.cxx
index c8077472f30..114f1ef86f5 100755
--- a/Database/CoraCool/src/CoraCoolFolder.cxx
+++ b/Database/CoraCool/src/CoraCoolFolder.cxx
@@ -139,7 +139,7 @@ int CoraCoolFolder::storeObject ATLAS_NOT_THREAD_SAFE (const cool::ValidityKey&
 		   const_iterator begin,
 		   const_iterator end,
 		   const cool::ChannelId& channelId,
-		   const std::string tagName,
+		   const std::string& tagName,
 		   const bool userTagOnly) {
   // store objects into CORAL table, and reference in COOL table
   // generate new FK and PK for CORAL data as needed
@@ -274,7 +274,7 @@ void CoraCoolFolder::referenceObject(const cool::ValidityKey& since,
 		       const cool::ValidityKey& until,
 		       const coral::Attribute& fkey,
 		       const cool::ChannelId& channelId,
-		       const std::string tagName,
+		       const std::string& tagName,
 		       const bool userTagOnly) {
   // add reference to existing payload object
   // call COOL API, just checking fkey has correct name
@@ -293,7 +293,7 @@ void CoraCoolFolder::referenceObject(const cool::ValidityKey& since,
 		       const cool::ValidityKey& until,
 		       const int ifkey,
 		       const cool::ChannelId& channelId,
-		       const std::string tagName,
+		       const std::string& tagName,
 		       const bool userTagOnly) {
   // add reference to existing payload object, supplying key as int
   cool::Record fkeylist(m_coolfolder->payloadSpecification());
@@ -531,7 +531,7 @@ void CoraCoolFolder::bulkInsert(const_iterator begin,const_iterator end,
 
 CoraCoolObjectPtr CoraCoolFolder::findObject(
    const cool::ValidityKey& pointInTime, const cool::ChannelId& channelId, 
-   const std::string tagName) {
+   const std::string& tagName) {
   // first query cool to get foreign key
   m_log << coral::Debug << "CoraCoolFolder query time " << pointInTime << 
     " channel " << channelId << " tag " << tagName << coral::MessageStream::endmsg;
-- 
GitLab