From 37a59a7a9e1af9fa81f92a3045f4a61c96382aff Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Wed, 7 Oct 2020 10:45:33 -0400 Subject: [PATCH] ByteStreamCnvSvcLegacy: Fix cppcheck warnings. - Prohibit copying of class owning memory. - Pass class instances by const reference, not by value. --- .../offline_EventStorage/v5_DataWriter.h | 58 +++++++++---------- .../offline_EventStorage/v5_DataBuffer.cxx | 5 +- .../offline_EventStorage/v5_DataWriter.cxx | 58 +++++++++---------- .../src/offline_EventStorage/v5_Guid.h | 9 ++- 4 files changed, 66 insertions(+), 64 deletions(-) diff --git a/Event/ByteStreamCnvSvcLegacy/ByteStreamCnvSvcLegacy/offline_EventStorage/v5_DataWriter.h b/Event/ByteStreamCnvSvcLegacy/ByteStreamCnvSvcLegacy/offline_EventStorage/v5_DataWriter.h index 0d11bd1199c..a2224310305 100644 --- a/Event/ByteStreamCnvSvcLegacy/ByteStreamCnvSvcLegacy/offline_EventStorage/v5_DataWriter.h +++ b/Event/ByteStreamCnvSvcLegacy/ByteStreamCnvSvcLegacy/offline_EventStorage/v5_DataWriter.h @@ -56,39 +56,39 @@ public: \param compression Compression type \param compLevel Compression level */ - DataWriter(const std::string writingPath, - const std::string fileNameCore, - const run_parameters_record rPar, - const std::vector<std::string> fmdStrings, + DataWriter(const std::string& writingPath, + const std::string& fileNameCore, + const run_parameters_record& rPar, + const std::vector<std::string>& fmdStrings, const unsigned int startIndex = 1, const CompressionType compression = NONE, const unsigned int compLevel = 1); - DataWriter(const std::string writingPath, + DataWriter(const std::string& writingPath, boost::shared_ptr<EventStorage::FileNameCallback> theFNCB, - const run_parameters_record rPar, - const std::string project, - const std::string streamType, - const std::string streamName, - const std::string stream, + const run_parameters_record& rPar, + const std::string& project, + const std::string& streamType, + const std::string& streamName, + const std::string& stream, const unsigned int lumiBlockNumber, - const std::string applicationName, - const std::vector<std::string> fmdStrings, + const std::string& applicationName, + const std::vector<std::string>& fmdStrings, const CompressionType compression = NONE, const unsigned int compLevel = 1); - DataWriter(const std::string writingPath, - const std::string fileNameCore, - const run_parameters_record rPar, - const std::string project, - const std::string streamType, - const std::string streamName, - const std::string stream, + DataWriter(const std::string& writingPath, + const std::string& fileNameCore, + const run_parameters_record& rPar, + const std::string& project, + const std::string& streamType, + const std::string& streamName, + const std::string& stream, const unsigned int lumiBlockNumber, - const std::string applicationName, - const std::vector<std::string> fmdStrings, + const std::string& applicationName, + const std::vector<std::string>& fmdStrings, const CompressionType compression = NONE, const unsigned int compLevel = 1); @@ -97,16 +97,16 @@ private: DataWriter(); - void initDW(const std::string writingPath, + void initDW(const std::string& writingPath, boost::shared_ptr<EventStorage::FileNameCallback> theFNCB, - const run_parameters_record rPar, - const std::string project, - const std::string streamType, - const std::string streamName, - const std::string stream, + const run_parameters_record& rPar, + const std::string& project, + const std::string& streamType, + const std::string& streamName, + const std::string& stream, const unsigned int lumiBlockNumber, - const std::string applicationName, - const std::vector<std::string> fmdStrings, + const std::string& applicationName, + const std::vector<std::string>& fmdStrings, const CompressionType compression, const unsigned int compLevel); diff --git a/Event/ByteStreamCnvSvcLegacy/src/offline_EventStorage/v5_DataBuffer.cxx b/Event/ByteStreamCnvSvcLegacy/src/offline_EventStorage/v5_DataBuffer.cxx index 7ca884a85fa..371f8bec8dd 100644 --- a/Event/ByteStreamCnvSvcLegacy/src/offline_EventStorage/v5_DataBuffer.cxx +++ b/Event/ByteStreamCnvSvcLegacy/src/offline_EventStorage/v5_DataBuffer.cxx @@ -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 */ @@ -21,6 +21,9 @@ public: m_buffer = new char[size]; m_buffersize = size; } + + implementation (const implementation&) = delete; + implementation& operator= (const implementation&) = delete; ~implementation() { delete[] m_buffer; } diff --git a/Event/ByteStreamCnvSvcLegacy/src/offline_EventStorage/v5_DataWriter.cxx b/Event/ByteStreamCnvSvcLegacy/src/offline_EventStorage/v5_DataWriter.cxx index 7fbbf10362e..3599b5dfffc 100644 --- a/Event/ByteStreamCnvSvcLegacy/src/offline_EventStorage/v5_DataWriter.cxx +++ b/Event/ByteStreamCnvSvcLegacy/src/offline_EventStorage/v5_DataWriter.cxx @@ -32,16 +32,16 @@ using EventStorage::SimpleFileName; // constructors DataWriter:: -DataWriter(const string writingPath, +DataWriter(const string& writingPath, boost::shared_ptr<FileNameCallback> theFNCB, - const run_parameters_record rPar, - const std::string project, - const std::string streamType, - const std::string streamName, - const std::string stream, + const run_parameters_record& rPar, + const std::string& project, + const std::string& streamType, + const std::string& streamName, + const std::string& stream, const unsigned int lumiBlockNumber, - const std::string applicationName, - const std::vector<std::string> fmdStrings, + const std::string& applicationName, + const std::vector<std::string>& fmdStrings, const CompressionType compression, const unsigned int compLevel) { @@ -50,10 +50,10 @@ DataWriter(const string writingPath, } DataWriter:: -DataWriter(const string writingPath, - const string fileNameCore, - const run_parameters_record rPar, - const freeMetaDataStrings fmdStrings, +DataWriter(const string& writingPath, + const string& fileNameCore, + const run_parameters_record& rPar, + const freeMetaDataStrings& fmdStrings, const unsigned int startIndex, const CompressionType compression, const unsigned int compLevel) @@ -95,16 +95,16 @@ DataWriter(const string writingPath, DataWriter:: -DataWriter(const string writingPath, - const string fileNameCore, - const run_parameters_record rPar, - const std::string project, - const std::string streamType, - const std::string streamName, - const std::string stream, +DataWriter(const string& writingPath, + const string& fileNameCore, + const run_parameters_record& rPar, + const std::string& project, + const std::string& streamType, + const std::string& streamName, + const std::string& stream, const unsigned int lumiBlockNumber, - const std::string applicationName, - const std::vector<std::string> fmdStrings, + const std::string& applicationName, + const std::vector<std::string>& fmdStrings, const CompressionType compression, const unsigned int compLevel) { @@ -128,16 +128,16 @@ DataWriter::~DataWriter() void DataWriter:: -initDW(const string writingPath, +initDW(const string& writingPath, boost::shared_ptr<FileNameCallback> theFNCB, - const run_parameters_record rPar, - const std::string project, - const std::string streamType, - const std::string streamName, - const std::string stream, + const run_parameters_record& rPar, + const std::string& project, + const std::string& streamType, + const std::string& streamName, + const std::string& stream, const unsigned int lumiBlockNumber, - const std::string applicationName, - const std::vector<std::string> fmdStrings, + const std::string& applicationName, + const std::vector<std::string>& fmdStrings, const CompressionType compression, const unsigned int compLevel) { diff --git a/Event/ByteStreamCnvSvcLegacy/src/offline_EventStorage/v5_Guid.h b/Event/ByteStreamCnvSvcLegacy/src/offline_EventStorage/v5_Guid.h index 9a97b32fcc7..cecf5214ead 100644 --- a/Event/ByteStreamCnvSvcLegacy/src/offline_EventStorage/v5_Guid.h +++ b/Event/ByteStreamCnvSvcLegacy/src/offline_EventStorage/v5_Guid.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 */ // This is a warapper class for uuid. @@ -53,10 +53,9 @@ namespace offline_poolCopy_v5 { Data1 = g.Data1; Data2 = g.Data2; Data3 = g.Data3; - unsigned int *p = (unsigned int*)&Data4[0]; - const unsigned int *q = (const unsigned int*)&g.Data4[0]; - *(p+1) = *(q+1); - *p = *q; + for (size_t i = 0; i < 8; i++) { + Data4[i] = g.Data4[i]; + } } return *this; } -- GitLab