From a21190fbee8bcbe82b19fd1074b9e623346d54d2 Mon Sep 17 00:00:00 2001 From: Niels Alexander Buegel Date: Fri, 28 Nov 2025 13:36:39 +0100 Subject: [PATCH] Move many things to in-class initialisers --- catalogue/dummy/DummyCatalogue.cpp | 44 +----- catalogue/dummy/DummyCatalogue.hpp | 64 +++++--- catalogue/rdbms/RdbmsAdminUserCatalogue.cpp | 2 +- catalogue/rdbms/RdbmsAdminUserCatalogue.hpp | 2 +- catalogue/rdbms/RdbmsArchiveFileCatalogue.cpp | 4 +- catalogue/rdbms/RdbmsArchiveFileCatalogue.hpp | 4 +- catalogue/rdbms/RdbmsCatalogue.cpp | 4 - catalogue/rdbms/RdbmsCatalogue.hpp | 8 +- cmdline/CtaAdminTextFormatter.hpp | 3 +- .../common/CmdLineArgs.cpp | 2 +- .../common/CmdLineArgs.hpp | 4 +- common/MountControl.hpp | 10 +- common/dataStructures/ArchiveFileSummary.cpp | 4 +- common/dataStructures/ArchiveFileSummary.hpp | 6 +- common/dataStructures/ArchiveJob.cpp | 4 +- common/dataStructures/ArchiveJob.hpp | 8 +- common/dataStructures/ArchiveRequest.cpp | 2 +- common/dataStructures/ArchiveRequest.hpp | 4 +- common/dataStructures/ArchiveRoute.cpp | 3 +- common/dataStructures/ArchiveRoute.hpp | 4 +- .../dataStructures/CancelRetrieveRequest.cpp | 3 +- .../dataStructures/CancelRetrieveRequest.hpp | 4 +- .../dataStructures/DeleteArchiveRequest.cpp | 5 +- .../dataStructures/DeleteArchiveRequest.hpp | 2 +- common/dataStructures/LogicalLibrary.cpp | 3 +- common/dataStructures/LogicalLibrary.hpp | 2 +- common/dataStructures/ReadTestResult.cpp | 6 +- common/dataStructures/ReadTestResult.hpp | 10 +- common/dataStructures/RetrieveRequest.cpp | 2 +- common/dataStructures/RetrieveRequest.hpp | 4 +- common/dataStructures/SecurityIdentity.cpp | 9 +- common/dataStructures/SecurityIdentity.hpp | 6 +- common/dataStructures/StorageClass.cpp | 5 +- common/dataStructures/StorageClass.hpp | 10 +- common/dataStructures/Tape.cpp | 12 +- common/dataStructures/Tape.hpp | 19 ++- common/dataStructures/TapeDrive.cpp | 6 +- common/dataStructures/TapeDrive.hpp | 8 +- common/dataStructures/TapeLog.cpp | 3 +- common/dataStructures/TapeLog.hpp | 2 +- .../UpdateFileStorageClassRequest.cpp | 3 +- .../UpdateFileStorageClassRequest.hpp | 6 +- common/dataStructures/WriteTestResult.cpp | 6 +- common/dataStructures/WriteTestResult.hpp | 10 +- common/exception/Backtrace.cpp | 2 +- common/exception/Exception.cpp | 13 +- common/log/Logger.cpp | 6 +- common/log/Logger.hpp | 2 +- common/threading/ChildProcess.hpp | 22 +-- common/threading/Daemon.cpp | 4 +- common/threading/Daemon.hpp | 4 +- common/threading/Thread.hpp | 6 +- disk/DiskFile.cpp | 14 +- disk/DiskFile.hpp | 14 +- disk/DiskFileImplementations.hpp | 32 ++-- frontend/common/DriveLsResponseStream.cpp | 3 +- frontend/common/DriveLsResponseStream.hpp | 4 +- .../common/FailedRequestLsResponseStream.cpp | 6 +- .../common/FailedRequestLsResponseStream.hpp | 6 +- frontend/common/FrontendService.cpp | 2 +- frontend/common/FrontendService.hpp | 2 +- .../grpc/ClientNegotiationRequestHandler.cpp | 33 ++-- .../grpc/ClientNegotiationRequestHandler.hpp | 14 +- .../grpc/ServerNegotiationRequestHandler.cpp | 2 - .../grpc/ServerNegotiationRequestHandler.hpp | 4 +- .../CtaAdminClientReadReactor.hpp | 3 +- .../CtaAdminServerWriteReactor.cpp | 5 +- .../CtaAdminServerWriteReactor.hpp | 4 +- frontend/grpc/callback_api/ServerVersion.hpp | 5 +- mediachanger/DebugBuf.cpp | 4 +- mediachanger/DebugBuf.hpp | 4 +- mediachanger/MessageHeader.cpp | 6 +- mediachanger/MessageHeader.hpp | 6 +- mediachanger/RmcMountMsgBody.cpp | 6 +- mediachanger/RmcMountMsgBody.hpp | 8 +- mediachanger/RmcUnmountMsgBody.cpp | 6 +- mediachanger/RmcUnmountMsgBody.hpp | 8 +- objectstore/AgentReference.cpp | 2 +- objectstore/AgentReference.hpp | 4 +- objectstore/BackendRados.cpp | 8 +- objectstore/BackendRados.hpp | 6 +- objectstore/BackendVFS.hpp | 6 +- objectstore/ObjectOps.hpp | 10 +- objectstore/RepackQueueAlgorithms.hpp | 4 +- rdbms/AutoRollback.cpp | 5 +- rdbms/AutoRollback.hpp | 4 +- rdbms/ConnPool.cpp | 3 +- rdbms/ConnPool.hpp | 2 +- rdbms/wrapper/ColumnNameToIdxAndType.hpp | 10 +- rdbms/wrapper/OcciColumn.cpp | 3 +- rdbms/wrapper/OcciColumn.hpp | 2 +- rdbms/wrapper/OcciConn.cpp | 1 - rdbms/wrapper/OcciConn.hpp | 2 +- rdbms/wrapper/PostgresRset.cpp | 4 +- rdbms/wrapper/PostgresRset.hpp | 4 +- rdbms/wrapper/PostgresStmt.cpp | 4 +- rdbms/wrapper/PostgresStmt.hpp | 4 +- rdbms/wrapper/SqliteRset.cpp | 10 +- rdbms/wrapper/SqliteStmt.cpp | 4 +- rdbms/wrapper/SqliteStmt.hpp | 4 +- scheduler/ArchiveMount.cpp | 5 +- scheduler/ArchiveMount.hpp | 2 +- scheduler/OStoreDB/MemQueues.hpp | 8 +- scheduler/OStoreDB/OStoreDB.cpp | 8 +- scheduler/OStoreDB/OStoreDB.hpp | 16 +- statistics/StatisticsSaveCmdLineArgs.cpp | 3 +- statistics/StatisticsSaveCmdLineArgs.hpp | 2 +- statistics/StatisticsUpdateCmdLineArgs.cpp | 3 +- statistics/StatisticsUpdateCmdLineArgs.hpp | 2 +- .../castor/tape/tapeserver/SCSI/Device.hpp | 9 +- .../tape/tapeserver/daemon/DataPipeline.hpp | 62 ++++---- .../tape/tapeserver/daemon/DiskStats.hpp | 75 ++++----- .../tapeserver/daemon/RecallReportPacker.cpp | 8 +- .../tapeserver/daemon/RecallReportPacker.hpp | 18 +-- .../daemon/ReportPackerInterface.hpp | 13 +- .../tapeserver/daemon/TapeSessionReporter.cpp | 14 +- .../tapeserver/daemon/TapeSessionReporter.hpp | 16 +- .../tapeserver/daemon/TapeSessionStats.hpp | 111 +++++++------- .../daemon/TapeSingleThreadInterface.hpp | 4 +- .../daemon/TapeWriteSingleThread.cpp | 2 - .../daemon/TapeWriteSingleThread.hpp | 4 +- .../tape/tapeserver/drive/DriveGeneric.cpp | 4 +- .../tape/tapeserver/drive/DriveGeneric.hpp | 4 +- .../tape/tapeserver/drive/DriveInterface.hpp | 11 +- .../tape/tapeserver/drive/FakeDrive.cpp | 8 +- .../tape/tapeserver/drive/FakeDrive.hpp | 6 +- .../tape/tapeserver/file/FileWriter.cpp | 3 +- .../tape/tapeserver/file/FileWriter.hpp | 6 +- .../tape/tapeserver/file/OsmFileStructure.cpp | 12 +- .../tape/tapeserver/file/OsmFileStructure.hpp | 8 +- .../tape/tapeserver/file/ReadSession.cpp | 4 +- .../tape/tapeserver/file/ReadSession.hpp | 10 +- .../tape/tapeserver/file/Structures.hpp | 84 +++++------ .../tape/tapeserver/file/WriteSession.cpp | 3 +- .../tape/tapeserver/file/WriteSession.hpp | 6 +- .../tape/tapeserver/system/FileWrappers.cpp | 97 ++++++------ .../tape/tapeserver/system/FileWrappers.hpp | 142 +++++++++--------- .../castor/tape/tapeserver/system/Wrapper.hpp | 19 ++- tapeserver/daemon/TapeDaemon.hpp | 17 +-- tapeserver/readtp/ReadtpCmdLineArgs.cpp | 11 +- tapeserver/readtp/ReadtpCmdLineArgs.hpp | 8 +- tapeserver/tapelabel/TapeLabelCmdLineArgs.cpp | 7 +- tapeserver/tapelabel/TapeLabelCmdLineArgs.hpp | 22 +-- tests/ImmutableFileTestCmdLineArgs.cpp | 3 +- tests/ImmutableFileTestCmdLineArgs.hpp | 2 +- 145 files changed, 695 insertions(+), 885 deletions(-) diff --git a/catalogue/dummy/DummyCatalogue.cpp b/catalogue/dummy/DummyCatalogue.cpp index cda07c6790..356a1ec164 100644 --- a/catalogue/dummy/DummyCatalogue.cpp +++ b/catalogue/dummy/DummyCatalogue.cpp @@ -16,52 +16,12 @@ */ #include - -#include "catalogue/dummy/DummyAdminUserCatalogue.hpp" -#include "catalogue/dummy/DummyArchiveFileCatalogue.hpp" -#include "catalogue/dummy/DummyArchiveRouteCatalogue.hpp" -#include "catalogue/dummy/DummyCatalogue.hpp" -#include "catalogue/dummy/DummyDiskInstanceCatalogue.hpp" -#include "catalogue/dummy/DummyDiskInstanceSpaceCatalogue.hpp" -#include "catalogue/dummy/DummyDiskSystemCatalogue.hpp" -#include "catalogue/dummy/DummyDriveConfigCatalogue.hpp" -#include "catalogue/dummy/DummyDriveStateCatalogue.hpp" -#include "catalogue/dummy/DummyFileRecycleLogCatalogue.hpp" -#include "catalogue/dummy/DummyMountPolicyCatalogue.hpp" -#include "catalogue/dummy/DummyRequesterActivityMountRuleCatalogue.hpp" -#include "catalogue/dummy/DummyRequesterGroupMountRuleCatalogue.hpp" -#include "catalogue/dummy/DummyRequesterMountRuleCatalogue.hpp" -#include "catalogue/dummy/DummySchemaCatalogue.hpp" -#include "catalogue/dummy/DummyStorageClassCatalogue.hpp" -#include "catalogue/dummy/DummyTapeCatalogue.hpp" -#include "catalogue/dummy/DummyTapeFileCatalogue.hpp" -#include "catalogue/dummy/DummyTapePoolCatalogue.hpp" -#include "catalogue/dummy/DummyVirtualOrganizationCatalogue.hpp" +#include "DummyCatalogue.hpp" namespace cta::catalogue { -DummyCatalogue::DummyCatalogue() - : m_schema(std::make_unique()), - m_adminUser(std::make_unique()), - m_diskSystem(std::make_unique()), - m_diskInstance(std::make_unique()), - m_diskInstanceSpace(std::make_unique()), - m_vo(std::make_unique()), - m_archiveRoute(std::make_unique()), - m_storageClass(std::make_unique()), - m_tapePool(std::make_unique()), - m_tape(std::make_unique()), - m_mountPolicy(std::make_unique()), - m_requesterActivityMountRule(std::make_unique()), - m_requesterMountRule(std::make_unique()), - m_requesterGroupMountRule(std::make_unique()), - m_tapeFile(std::make_unique()), - m_fileRecycleLog(std::make_unique()), - m_driveConfig(std::make_unique()), - m_archiveFile(std::make_unique()), - m_driveState(std::make_unique()) { -} +DummyCatalogue::DummyCatalogue() {} const std::unique_ptr& DummyCatalogue::Schema() { return m_schema; diff --git a/catalogue/dummy/DummyCatalogue.hpp b/catalogue/dummy/DummyCatalogue.hpp index be3df3d225..1bce6385b2 100644 --- a/catalogue/dummy/DummyCatalogue.hpp +++ b/catalogue/dummy/DummyCatalogue.hpp @@ -21,6 +21,26 @@ #include "catalogue/Catalogue.hpp" +#include "catalogue/dummy/DummyAdminUserCatalogue.hpp" +#include "catalogue/dummy/DummyArchiveFileCatalogue.hpp" +#include "catalogue/dummy/DummyArchiveRouteCatalogue.hpp" +#include "catalogue/dummy/DummyDiskInstanceCatalogue.hpp" +#include "catalogue/dummy/DummyDiskInstanceSpaceCatalogue.hpp" +#include "catalogue/dummy/DummyDiskSystemCatalogue.hpp" +#include "catalogue/dummy/DummyDriveConfigCatalogue.hpp" +#include "catalogue/dummy/DummyDriveStateCatalogue.hpp" +#include "catalogue/dummy/DummyFileRecycleLogCatalogue.hpp" +#include "catalogue/dummy/DummyMountPolicyCatalogue.hpp" +#include "catalogue/dummy/DummyRequesterActivityMountRuleCatalogue.hpp" +#include "catalogue/dummy/DummyRequesterGroupMountRuleCatalogue.hpp" +#include "catalogue/dummy/DummyRequesterMountRuleCatalogue.hpp" +#include "catalogue/dummy/DummySchemaCatalogue.hpp" +#include "catalogue/dummy/DummyStorageClassCatalogue.hpp" +#include "catalogue/dummy/DummyTapeCatalogue.hpp" +#include "catalogue/dummy/DummyTapeFileCatalogue.hpp" +#include "catalogue/dummy/DummyTapePoolCatalogue.hpp" +#include "catalogue/dummy/DummyVirtualOrganizationCatalogue.hpp" + namespace cta::catalogue { /** @@ -58,28 +78,28 @@ public: const std::unique_ptr& DriveState() override; protected: - std::unique_ptr m_schema; - std::unique_ptr m_adminUser; - std::unique_ptr m_diskSystem; - std::unique_ptr m_diskInstance; - std::unique_ptr m_diskInstanceSpace; - std::unique_ptr m_vo; - std::unique_ptr m_archiveRoute; - std::unique_ptr m_mediaType; - std::unique_ptr m_storageClass; - std::unique_ptr m_tapePool; - std::unique_ptr m_tape; - std::unique_ptr m_mountPolicy; - std::unique_ptr m_requesterActivityMountRule; - std::unique_ptr m_requesterMountRule; - std::unique_ptr m_requesterGroupMountRule; - std::unique_ptr m_logicalLibrary; - std::unique_ptr m_physicalLibrary; - std::unique_ptr m_tapeFile; - std::unique_ptr m_fileRecycleLog; - std::unique_ptr m_driveConfig; - std::unique_ptr m_archiveFile; - std::unique_ptr m_driveState; + std::unique_ptr m_schema = std::make_unique(); + std::unique_ptr m_adminUser = std::make_unique(); + std::unique_ptr m_diskSystem = std::make_unique(); + std::unique_ptr m_diskInstance = std::make_unique(); + std::unique_ptr m_diskInstanceSpace = std::make_unique(); + std::unique_ptr m_vo = std::make_unique(); + std::unique_ptr m_archiveRoute = std::make_unique(); + std::unique_ptr m_mediaType = nullptr; + std::unique_ptr m_storageClass = std::make_unique(); + std::unique_ptr m_tapePool = std::make_unique(); + std::unique_ptr m_tape = std::make_unique(); + std::unique_ptr m_mountPolicy = std::make_unique(); + std::unique_ptr m_requesterActivityMountRule = std::make_unique(); + std::unique_ptr m_requesterMountRule = std::make_unique(); + std::unique_ptr m_requesterGroupMountRule = std::make_unique(); + std::unique_ptr m_logicalLibrary = nullptr; + std::unique_ptr m_physicalLibrary = nullptr; + std::unique_ptr m_tapeFile = std::make_unique(); + std::unique_ptr m_fileRecycleLog = std::make_unique(); + std::unique_ptr m_driveConfig = std::make_unique(); + std::unique_ptr m_archiveFile = std::make_unique(); + std::unique_ptr m_driveState = std::make_unique(); }; } // namespace cta::catalogue diff --git a/catalogue/rdbms/RdbmsAdminUserCatalogue.cpp b/catalogue/rdbms/RdbmsAdminUserCatalogue.cpp index 063e1a21f7..123b8c2a01 100644 --- a/catalogue/rdbms/RdbmsAdminUserCatalogue.cpp +++ b/catalogue/rdbms/RdbmsAdminUserCatalogue.cpp @@ -31,7 +31,7 @@ namespace cta::catalogue { RdbmsAdminUserCatalogue::RdbmsAdminUserCatalogue(log::Logger &log, std::shared_ptr connPool): - m_log(log), m_connPool(connPool), m_isAdminCache(10) {} + m_log(log), m_connPool(connPool) {} void RdbmsAdminUserCatalogue::createAdminUser( const common::dataStructures::SecurityIdentity &admin, diff --git a/catalogue/rdbms/RdbmsAdminUserCatalogue.hpp b/catalogue/rdbms/RdbmsAdminUserCatalogue.hpp index 8c0b6f5763..3c440782a8 100644 --- a/catalogue/rdbms/RdbmsAdminUserCatalogue.hpp +++ b/catalogue/rdbms/RdbmsAdminUserCatalogue.hpp @@ -83,7 +83,7 @@ private: /** * Cached version of isAdmin() results. */ - mutable TimeBasedCache m_isAdminCache; + mutable TimeBasedCache m_isAdminCache{10}; }; }} // namespace cta::catalogue diff --git a/catalogue/rdbms/RdbmsArchiveFileCatalogue.cpp b/catalogue/rdbms/RdbmsArchiveFileCatalogue.cpp index 6df46a974d..d841402442 100644 --- a/catalogue/rdbms/RdbmsArchiveFileCatalogue.cpp +++ b/catalogue/rdbms/RdbmsArchiveFileCatalogue.cpp @@ -51,9 +51,7 @@ RdbmsArchiveFileCatalogue::RdbmsArchiveFileCatalogue(log::Logger &log, std::shar RdbmsCatalogue *rdbmsCatalogue) : m_log(log), m_connPool(connPool), - m_rdbmsCatalogue(rdbmsCatalogue), - m_tapeCopyToPoolCache(10), - m_expectedNbArchiveRoutesCache(10) {} + m_rdbmsCatalogue(rdbmsCatalogue) {} uint64_t RdbmsArchiveFileCatalogue::checkAndGetNextArchiveFileId(const std::string &diskInstanceName, const std::string &storageClassName, const common::dataStructures::RequesterIdentity &user) { diff --git a/catalogue/rdbms/RdbmsArchiveFileCatalogue.hpp b/catalogue/rdbms/RdbmsArchiveFileCatalogue.hpp index d59e94248a..e1b438b321 100644 --- a/catalogue/rdbms/RdbmsArchiveFileCatalogue.hpp +++ b/catalogue/rdbms/RdbmsArchiveFileCatalogue.hpp @@ -146,7 +146,7 @@ private: * Cached versions of tape copy to tape tape pool mappings for specific * storage classes. */ - mutable TimeBasedCache m_tapeCopyToPoolCache; + mutable TimeBasedCache m_tapeCopyToPoolCache{10}; /** * Cached versions of the expected number of archive routes for specific @@ -154,7 +154,7 @@ private: * method as opposed to the actual number entered so far using the * createArchiveRoute() method. */ - mutable TimeBasedCache m_expectedNbArchiveRoutesCache; + mutable TimeBasedCache m_expectedNbArchiveRoutesCache{10}; /** * Returns a cached version of the mapping from tape copy to tape pool for the diff --git a/catalogue/rdbms/RdbmsCatalogue.cpp b/catalogue/rdbms/RdbmsCatalogue.cpp index e8ff58b175..a87923179c 100644 --- a/catalogue/rdbms/RdbmsCatalogue.cpp +++ b/catalogue/rdbms/RdbmsCatalogue.cpp @@ -57,10 +57,6 @@ RdbmsCatalogue::RdbmsCatalogue( m_log(log), m_connPool(std::make_shared(login, nbConns)), m_archiveFileListingConnPool(std::make_shared(login, nbArchiveFileListingConns)), - m_groupMountPolicyCache(10), - m_userMountPolicyCache(10), - m_allMountPoliciesCache(60), - m_tapepoolVirtualOrganizationCache(60), m_schema(std::make_unique(m_log, m_connPool)), m_adminUser(std::make_unique(m_log, m_connPool)), m_diskSystem(std::make_unique(m_log, m_connPool)), diff --git a/catalogue/rdbms/RdbmsCatalogue.hpp b/catalogue/rdbms/RdbmsCatalogue.hpp index bd2f722a3d..8327eef82b 100644 --- a/catalogue/rdbms/RdbmsCatalogue.hpp +++ b/catalogue/rdbms/RdbmsCatalogue.hpp @@ -137,24 +137,24 @@ protected: /** * Cached versions of mount policies for specific user groups. */ - mutable TimeBasedCache > m_groupMountPolicyCache; + mutable TimeBasedCache > m_groupMountPolicyCache{10}; /** * Cached versions of mount policies for specific users. */ - mutable TimeBasedCache > m_userMountPolicyCache; + mutable TimeBasedCache > m_userMountPolicyCache{10}; /** * Cached versions of all mount policies */ - mutable TimeBasedCache> m_allMountPoliciesCache; + mutable TimeBasedCache> m_allMountPoliciesCache{60}; friend class RdbmsVirtualOrganizationCatalogue; friend class RdbmsTapePoolCatalogue; /** * Cached versions of virtual organization for specific tapepools */ - mutable TimeBasedCache m_tapepoolVirtualOrganizationCache; + mutable TimeBasedCache m_tapepoolVirtualOrganizationCache{60}; protected: std::unique_ptr m_schema; diff --git a/cmdline/CtaAdminTextFormatter.hpp b/cmdline/CtaAdminTextFormatter.hpp index d1340c0dc0..fabefa481b 100644 --- a/cmdline/CtaAdminTextFormatter.hpp +++ b/cmdline/CtaAdminTextFormatter.hpp @@ -36,7 +36,6 @@ public: */ explicit TextFormatter(unsigned int bufLines = 1000) : m_bufLines(bufLines) { m_outputBuffer.reserve(bufLines); - m_lastColumnFlushLeft = false; } ~TextFormatter(); @@ -162,7 +161,7 @@ private: std::vector m_colSize; //!< Array of column sizes unsigned int m_bufLines; //!< Number of text lines to buffer before flushing formatted output std::vector> m_outputBuffer; //!< Buffer for text output (not used for JSON) - bool m_lastColumnFlushLeft; //!< Flag indicating if last collumn should be aligned left + bool m_lastColumnFlushLeft = false; //!< Flag indicating if last collumn should be aligned left static constexpr const char* const TEXT_RED = "\x1b[31;1m"; //!< Terminal formatting code for red text static constexpr const char* const TEXT_NORMAL = "\x1b[0m"; //!< Terminal formatting code for normal text static constexpr const int NB_CHAR_REASON = diff --git a/cmdline/standalone_cli_tools/common/CmdLineArgs.cpp b/cmdline/standalone_cli_tools/common/CmdLineArgs.cpp index 46fcca8443..ab79f1593e 100644 --- a/cmdline/standalone_cli_tools/common/CmdLineArgs.cpp +++ b/cmdline/standalone_cli_tools/common/CmdLineArgs.cpp @@ -98,7 +98,7 @@ std::map shortopts = { // constructor //------------------------------------------------------------------------------ CmdLineArgs::CmdLineArgs(const int &argc, char *const *const &argv, const StandaloneCliTool &standaloneCliTool): -m_help(false), m_debug(false), m_standaloneCliTool{standaloneCliTool} { +m_standaloneCliTool{standaloneCliTool} { opterr = 0; int opt = 0; diff --git a/cmdline/standalone_cli_tools/common/CmdLineArgs.hpp b/cmdline/standalone_cli_tools/common/CmdLineArgs.hpp index 765c503a9d..025fa17eff 100644 --- a/cmdline/standalone_cli_tools/common/CmdLineArgs.hpp +++ b/cmdline/standalone_cli_tools/common/CmdLineArgs.hpp @@ -44,12 +44,12 @@ struct CmdLineArgs { /** * True if the usage message should be printed. */ - bool m_help; + bool m_help = false; /** * True if debug messages should be printed */ - bool m_debug; + bool m_debug = false; /** * Archive file id of the files to restore diff --git a/common/MountControl.hpp b/common/MountControl.hpp index 5a1a1e4ea9..f0a3b007da 100644 --- a/common/MountControl.hpp +++ b/common/MountControl.hpp @@ -22,24 +22,24 @@ namespace cta { * Description of the criteria to mount a tape */ struct MountCriteria { - uint64_t maxFilesQueued; /**< The maximum number of files to be queued + uint64_t maxFilesQueued; /**< The maximum number of files to be queued * before trigerring a mount */ uint64_t maxBytesQueued; /**< The maximum amount a data before trigerring * a request */ uint64_t maxAge; /**< The maximum age for a request before trigerring * a request (in seconds) */ uint16_t quota; /**< The maximum number of mounts for this tape pool */ - MountCriteria(uint64_t mf, uint64_t mb, uint64_t ma, + MountCriteria(uint64_t mf, uint64_t mb, uint64_t ma, uint16_t q): maxFilesQueued(mf), maxBytesQueued(mb), maxAge(ma), quota(q) {} MountCriteria(): maxFilesQueued(0), maxBytesQueued(0), maxAge(0), quota(0) {} }; - + struct MountCriteriaByDirection { MountCriteria archive; MountCriteria retrieve; MountCriteriaByDirection(const MountCriteria& a, const MountCriteria & r): archive(a), retrieve(r) {} - MountCriteriaByDirection(): archive(), retrieve() {} + MountCriteriaByDirection() {} }; -} \ No newline at end of file +} diff --git a/common/dataStructures/ArchiveFileSummary.cpp b/common/dataStructures/ArchiveFileSummary.cpp index 8eb230a5b0..fae90698b2 100644 --- a/common/dataStructures/ArchiveFileSummary.cpp +++ b/common/dataStructures/ArchiveFileSummary.cpp @@ -24,9 +24,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -ArchiveFileSummary::ArchiveFileSummary(): - totalBytes(0), - totalFiles(0) {} +ArchiveFileSummary::ArchiveFileSummary() {} //------------------------------------------------------------------------------ // operator== diff --git a/common/dataStructures/ArchiveFileSummary.hpp b/common/dataStructures/ArchiveFileSummary.hpp index 94a5e5da2f..64a8858bf8 100644 --- a/common/dataStructures/ArchiveFileSummary.hpp +++ b/common/dataStructures/ArchiveFileSummary.hpp @@ -26,7 +26,7 @@ namespace cta::common::dataStructures { /** - * This struct is used to hold stats of a list of files (when listing them) + * This struct is used to hold stats of a list of files (when listing them) */ struct ArchiveFileSummary { @@ -36,8 +36,8 @@ struct ArchiveFileSummary { bool operator!=(const ArchiveFileSummary &rhs) const; - uint64_t totalBytes; - uint64_t totalFiles; + uint64_t totalBytes = 0; + uint64_t totalFiles = 0; }; // struct ArchiveFileSummary diff --git a/common/dataStructures/ArchiveJob.cpp b/common/dataStructures/ArchiveJob.cpp index 965953acbe..080d23d07c 100644 --- a/common/dataStructures/ArchiveJob.cpp +++ b/common/dataStructures/ArchiveJob.cpp @@ -24,9 +24,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -ArchiveJob::ArchiveJob(): - copyNumber(0), - archiveFileID(0) {} +ArchiveJob::ArchiveJob() {} //------------------------------------------------------------------------------ // operator== diff --git a/common/dataStructures/ArchiveJob.hpp b/common/dataStructures/ArchiveJob.hpp index ef5221b80f..28d032b88e 100644 --- a/common/dataStructures/ArchiveJob.hpp +++ b/common/dataStructures/ArchiveJob.hpp @@ -26,8 +26,8 @@ namespace cta::common::dataStructures { /** - * The archive job contains the original request, and all data needed to queue - * the request in the system + * The archive job contains the original request, and all data needed to queue + * the request in the system */ struct ArchiveJob { @@ -40,8 +40,8 @@ struct ArchiveJob { ArchiveRequest request; std::string tapePool; std::string instanceName; - uint32_t copyNumber; - uint64_t archiveFileID; + uint32_t copyNumber = 0; + uint64_t archiveFileID = 0; std::string objectId; //!< Objectstore address, provided when reporting a failed job std::list failurelogs; std::list reportfailurelogs; diff --git a/common/dataStructures/ArchiveRequest.cpp b/common/dataStructures/ArchiveRequest.cpp index e005e3b1c6..14c4b5a724 100644 --- a/common/dataStructures/ArchiveRequest.cpp +++ b/common/dataStructures/ArchiveRequest.cpp @@ -24,7 +24,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -ArchiveRequest::ArchiveRequest(): fileSize(0) {} +ArchiveRequest::ArchiveRequest() {} //------------------------------------------------------------------------------ // operator== diff --git a/common/dataStructures/ArchiveRequest.hpp b/common/dataStructures/ArchiveRequest.hpp index 539642322e..cbf6d19ab9 100644 --- a/common/dataStructures/ArchiveRequest.hpp +++ b/common/dataStructures/ArchiveRequest.hpp @@ -30,7 +30,7 @@ namespace cta::common::dataStructures { /** - * This struct holds all the command line parameters of a CTA archive command + * This struct holds all the command line parameters of a CTA archive command */ struct ArchiveRequest { @@ -44,7 +44,7 @@ struct ArchiveRequest { std::string diskFileID; std::string srcURL; - uint64_t fileSize; + uint64_t fileSize = 0; checksum::ChecksumBlob checksumBlob; std::string storageClass; DiskFileInfo diskFileInfo; diff --git a/common/dataStructures/ArchiveRoute.cpp b/common/dataStructures/ArchiveRoute.cpp index 4eb0fcefca..5941a708e8 100644 --- a/common/dataStructures/ArchiveRoute.cpp +++ b/common/dataStructures/ArchiveRoute.cpp @@ -27,8 +27,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -ArchiveRoute::ArchiveRoute(): - copyNb(0), type(ArchiveRouteType::DEFAULT) {} +ArchiveRoute::ArchiveRoute() {} //------------------------------------------------------------------------------ // operator== diff --git a/common/dataStructures/ArchiveRoute.hpp b/common/dataStructures/ArchiveRoute.hpp index 588f734f82..81f764e5b9 100644 --- a/common/dataStructures/ArchiveRoute.hpp +++ b/common/dataStructures/ArchiveRoute.hpp @@ -48,12 +48,12 @@ struct ArchiveRoute { /** * The copy number of the tape file. */ - uint8_t copyNb; + uint8_t copyNb = 0; /** * The type of the archive route. */ - ArchiveRouteType type; + ArchiveRouteType type = ArchiveRouteType::DEFAULT; std::string tapePoolName; EntryLog creationLog; diff --git a/common/dataStructures/CancelRetrieveRequest.cpp b/common/dataStructures/CancelRetrieveRequest.cpp index e756dee0a9..2bad6cb39c 100644 --- a/common/dataStructures/CancelRetrieveRequest.cpp +++ b/common/dataStructures/CancelRetrieveRequest.cpp @@ -24,8 +24,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -CancelRetrieveRequest::CancelRetrieveRequest(): - archiveFileID(0) {} +CancelRetrieveRequest::CancelRetrieveRequest() {} //------------------------------------------------------------------------------ // operator== diff --git a/common/dataStructures/CancelRetrieveRequest.hpp b/common/dataStructures/CancelRetrieveRequest.hpp index ce7acba86b..6016180283 100644 --- a/common/dataStructures/CancelRetrieveRequest.hpp +++ b/common/dataStructures/CancelRetrieveRequest.hpp @@ -28,7 +28,7 @@ namespace cta::common::dataStructures { /** - * This is the request to cancel and ongoing retrieval + * This is the request to cancel and ongoing retrieval */ struct CancelRetrieveRequest { @@ -39,7 +39,7 @@ struct CancelRetrieveRequest { bool operator!=(const CancelRetrieveRequest &rhs) const; RequesterIdentity requester; - uint64_t archiveFileID; + uint64_t archiveFileID = 0; std::string dstURL; DiskFileInfo diskFileInfo; std::string retrieveRequestId; diff --git a/common/dataStructures/DeleteArchiveRequest.cpp b/common/dataStructures/DeleteArchiveRequest.cpp index b3100dd0d9..a02d50b0db 100644 --- a/common/dataStructures/DeleteArchiveRequest.cpp +++ b/common/dataStructures/DeleteArchiveRequest.cpp @@ -24,8 +24,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -DeleteArchiveRequest::DeleteArchiveRequest(): - archiveFileID(0) {} +DeleteArchiveRequest::DeleteArchiveRequest() {} //------------------------------------------------------------------------------ // operator== @@ -48,7 +47,7 @@ bool DeleteArchiveRequest::operator!=(const DeleteArchiveRequest &rhs) const { //------------------------------------------------------------------------------ std::ostream &operator<<(std::ostream &os, const DeleteArchiveRequest &obj) { os << "(requester=" << obj.requester - << " archiveFileID=" << obj.archiveFileID + << " archiveFileID=" << obj.archiveFileID << " diskFileId=" << obj.diskFileId << " diskFilePath=" << obj.diskFilePath << " recycleTime=" << obj.recycleTime diff --git a/common/dataStructures/DeleteArchiveRequest.hpp b/common/dataStructures/DeleteArchiveRequest.hpp index e8606fd265..b3355defdc 100644 --- a/common/dataStructures/DeleteArchiveRequest.hpp +++ b/common/dataStructures/DeleteArchiveRequest.hpp @@ -42,7 +42,7 @@ struct DeleteArchiveRequest { bool operator!=(const DeleteArchiveRequest &rhs) const; RequesterIdentity requester; - uint64_t archiveFileID; + uint64_t archiveFileID = 0; std::optional address; std::string diskFilePath; std::string diskFileId; diff --git a/common/dataStructures/LogicalLibrary.cpp b/common/dataStructures/LogicalLibrary.cpp index 93ccc4604a..2a24c40624 100644 --- a/common/dataStructures/LogicalLibrary.cpp +++ b/common/dataStructures/LogicalLibrary.cpp @@ -24,8 +24,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -LogicalLibrary::LogicalLibrary(): isDisabled(false) { -} +LogicalLibrary::LogicalLibrary() {} //------------------------------------------------------------------------------ // operator== diff --git a/common/dataStructures/LogicalLibrary.hpp b/common/dataStructures/LogicalLibrary.hpp index 6d3989a4d8..836dc43d6a 100644 --- a/common/dataStructures/LogicalLibrary.hpp +++ b/common/dataStructures/LogicalLibrary.hpp @@ -45,7 +45,7 @@ struct LogicalLibrary { bool operator!=(const LogicalLibrary &rhs) const; std::string name; - bool isDisabled; + bool isDisabled = false; EntryLog creationLog; EntryLog lastModificationLog; std::string comment; diff --git a/common/dataStructures/ReadTestResult.cpp b/common/dataStructures/ReadTestResult.cpp index 42193891c7..b24770d591 100644 --- a/common/dataStructures/ReadTestResult.cpp +++ b/common/dataStructures/ReadTestResult.cpp @@ -24,11 +24,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -ReadTestResult::ReadTestResult(): - noOfFilesRead(0), - totalBytesRead(0), - totalFilesRead(0), - totalTimeInSeconds(0) {} +ReadTestResult::ReadTestResult() {} //------------------------------------------------------------------------------ // operator== diff --git a/common/dataStructures/ReadTestResult.hpp b/common/dataStructures/ReadTestResult.hpp index 132fc9e73b..8fd35c21db 100644 --- a/common/dataStructures/ReadTestResult.hpp +++ b/common/dataStructures/ReadTestResult.hpp @@ -26,7 +26,7 @@ namespace cta::common::dataStructures { /** - * This is the result of a read test operation + * This is the result of a read test operation */ struct ReadTestResult { @@ -38,12 +38,12 @@ struct ReadTestResult { std::string driveName; std::string vid; - uint64_t noOfFilesRead; + uint64_t noOfFilesRead = 0; std::map errors; std::map> checksums; - uint64_t totalBytesRead; - uint64_t totalFilesRead; - uint64_t totalTimeInSeconds; + uint64_t totalBytesRead = 0; + uint64_t totalFilesRead = 0; + uint64_t totalTimeInSeconds = 0; }; // struct ReadTestResult diff --git a/common/dataStructures/RetrieveRequest.cpp b/common/dataStructures/RetrieveRequest.cpp index a1e857de3e..1e743bfd11 100644 --- a/common/dataStructures/RetrieveRequest.cpp +++ b/common/dataStructures/RetrieveRequest.cpp @@ -25,7 +25,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -RetrieveRequest::RetrieveRequest(): archiveFileID(0), isVerifyOnly(false) {} +RetrieveRequest::RetrieveRequest() {} //------------------------------------------------------------------------------ // operator== diff --git a/common/dataStructures/RetrieveRequest.hpp b/common/dataStructures/RetrieveRequest.hpp index 39cb159c78..05510e1c05 100644 --- a/common/dataStructures/RetrieveRequest.hpp +++ b/common/dataStructures/RetrieveRequest.hpp @@ -50,13 +50,13 @@ struct RetrieveRequest { void appendFileSizeToDstURL(const uint64_t fileSize); RequesterIdentity requester; - uint64_t archiveFileID; + uint64_t archiveFileID = 0; std::string dstURL; std::string retrieveReportURL; std::string errorReportURL; DiskFileInfo diskFileInfo; EntryLog creationLog; - bool isVerifyOnly; // request to retrieve file from tape but do not write a disk copy + bool isVerifyOnly = false; // request to retrieve file from tape but do not write a disk copy std::optional vid; // limit retrieve requests to the specified vid (in the case of dual-copy files) std::optional mountPolicy; // limit retrieve requests to a specified mount policy (only used for verification requests) LifecycleTimings lifecycleTimings; diff --git a/common/dataStructures/SecurityIdentity.cpp b/common/dataStructures/SecurityIdentity.cpp index a84e032d36..842ef70e9a 100644 --- a/common/dataStructures/SecurityIdentity.cpp +++ b/common/dataStructures/SecurityIdentity.cpp @@ -24,20 +24,19 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -SecurityIdentity::SecurityIdentity() : - authProtocol(Protocol::NONE) {} +SecurityIdentity::SecurityIdentity() {} //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ SecurityIdentity::SecurityIdentity(const std::string& username, const std::string& host) : - username(username), host(host), authProtocol(Protocol::NONE) {} + username(username), host(host) {} //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ SecurityIdentity::SecurityIdentity(const std::string& username, const std::string& host, const std::string& clientHost, const std::string& auth) : - username(username), host(host), clientHost(clientHost), authProtocol(Protocol::NONE) { + username(username), host(host), clientHost(clientHost) { if(!auth.empty()) { // Map the client protocol string to enum value auto proto_it = m_authProtoMap.find(auth); @@ -81,7 +80,7 @@ bool SecurityIdentity::operator<(const SecurityIdentity &rhs) const { //------------------------------------------------------------------------------ std::ostream &operator<<(std::ostream &os, const SecurityIdentity &obj) { os << "(username=" << obj.username - << " host=" << obj.host + << " host=" << obj.host << " clientHost=" << obj.clientHost << ")"; return os; } diff --git a/common/dataStructures/SecurityIdentity.hpp b/common/dataStructures/SecurityIdentity.hpp index d4556ca676..3ad5cb98b5 100644 --- a/common/dataStructures/SecurityIdentity.hpp +++ b/common/dataStructures/SecurityIdentity.hpp @@ -25,12 +25,12 @@ namespace cta::common::dataStructures { /** - * This struct holds the information about who issued the CTA command and from which host + * This struct holds the information about who issued the CTA command and from which host */ struct SecurityIdentity { SecurityIdentity(); - + SecurityIdentity(const std::string& username, const std::string& host); SecurityIdentity(const std::string& username, const std::string& host, const std::string& clientHost, const std::string& auth); @@ -52,7 +52,7 @@ struct SecurityIdentity { std::string username; std::string host; std::string clientHost; - Protocol authProtocol; + Protocol authProtocol = Protocol::NONE; }; // struct SecurityIdentity std::ostream &operator<<(std::ostream &os, const SecurityIdentity &obj); diff --git a/common/dataStructures/StorageClass.cpp b/common/dataStructures/StorageClass.cpp index e843e24843..1f82d658c4 100644 --- a/common/dataStructures/StorageClass.cpp +++ b/common/dataStructures/StorageClass.cpp @@ -24,8 +24,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -StorageClass::StorageClass(): - nbCopies(0) {} +StorageClass::StorageClass() {} //------------------------------------------------------------------------------ // operator== @@ -47,7 +46,7 @@ bool StorageClass::operator!=(const StorageClass &rhs) const { std::ostream &operator<<(std::ostream &os, const StorageClass &obj) { os << "(name=" << obj.name << " nbCopies=" << obj.nbCopies - << " vo=" << obj.vo.name + << " vo=" << obj.vo.name << " creationLog=" << obj.creationLog << " lastModificationLog=" << obj.lastModificationLog << " comment=" << obj.comment << ")"; diff --git a/common/dataStructures/StorageClass.hpp b/common/dataStructures/StorageClass.hpp index 6468dae980..66eef31651 100644 --- a/common/dataStructures/StorageClass.hpp +++ b/common/dataStructures/StorageClass.hpp @@ -28,9 +28,9 @@ namespace cta::common::dataStructures { /** - * This struct specifies the number of copies that a file tagged with it should - * have. it may also indicate the VO owning the file and what kind of data the - * file contains + * This struct specifies the number of copies that a file tagged with it should + * have. it may also indicate the VO owning the file and what kind of data the + * file contains */ struct StorageClass { @@ -79,8 +79,8 @@ struct StorageClass { /** * The number of copies on tape. */ - uint64_t nbCopies; - + uint64_t nbCopies = 0; + /** * The virtual organization to which this storage class belongs */ diff --git a/common/dataStructures/Tape.cpp b/common/dataStructures/Tape.cpp index 3eccc11538..f434d61a66 100644 --- a/common/dataStructures/Tape.cpp +++ b/common/dataStructures/Tape.cpp @@ -25,15 +25,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -Tape::Tape(): - lastFSeq(0), - capacityInBytes(0), - dataOnTapeInBytes(0), - nbMasterFiles(0), - masterDataInBytes(0), - full(false), - state(Tape::State::ACTIVE) - {} +Tape::Tape() {} const std::map Tape::STATE_TO_STRING_MAP = { {Tape::State::ACTIVE,"ACTIVE"}, @@ -170,7 +162,7 @@ std::ostream &operator<<(std::ostream &os, const Tape &obj) { << " capacityInBytes=" << obj.capacityInBytes << " dataOnTapeInBytes=" << obj.dataOnTapeInBytes << " encryptionKeyName=" << (obj.encryptionKeyName ? obj.encryptionKeyName.value() : "null") - << " full=" << obj.full + << " full=" << obj.full << " creationLog=" << obj.creationLog << " lastModificationLog=" << obj.lastModificationLog << " comment=" << obj.comment diff --git a/common/dataStructures/Tape.hpp b/common/dataStructures/Tape.hpp index 6e087708e4..e7c4e494b2 100644 --- a/common/dataStructures/Tape.hpp +++ b/common/dataStructures/Tape.hpp @@ -83,14 +83,14 @@ struct Tape { std::string vid; std::string mediaType; std::string vendor; - uint64_t lastFSeq; + uint64_t lastFSeq = 0; std::string logicalLibraryName; std::string tapePoolName; std::string vo; - uint64_t capacityInBytes; - uint64_t dataOnTapeInBytes; - uint64_t nbMasterFiles; - uint64_t masterDataInBytes; + uint64_t capacityInBytes = 0; + uint64_t dataOnTapeInBytes = 0; + uint64_t nbMasterFiles = 0; + uint64_t masterDataInBytes = 0; cta::common::dataStructures::Label::Format labelFormat; @@ -102,10 +102,9 @@ struct Tape { */ std::optional encryptionKeyName; - bool full; - bool disabled; - bool isFromCastor; - bool dirty; + bool full = false; + bool isFromCastor = false; + bool dirty = false; uint64_t readMountCount; uint64_t writeMountCount; EntryLog creationLog; @@ -117,7 +116,7 @@ struct Tape { std::optional purchaseOrder; std::optional physicalLibraryName; - State state; + State state = Tape::State::ACTIVE; std::optional stateReason; std::string stateModifiedBy; time_t stateUpdateTime; diff --git a/common/dataStructures/TapeDrive.cpp b/common/dataStructures/TapeDrive.cpp index 8479eb004f..48a08190ac 100644 --- a/common/dataStructures/TapeDrive.cpp +++ b/common/dataStructures/TapeDrive.cpp @@ -25,11 +25,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -TapeDrive::TapeDrive(): - driveStatus(DriveStatus::Unknown), - desiredUp(false), - desiredForceDown(false), - nextMountType(MountType::NoMount) {} +TapeDrive::TapeDrive() {} const std::map TapeDrive::STATE_TO_STRING_MAP = { {DriveStatus::Unknown, "UNKNOWN"}, diff --git a/common/dataStructures/TapeDrive.hpp b/common/dataStructures/TapeDrive.hpp index 4710c9a335..63de695962 100644 --- a/common/dataStructures/TapeDrive.hpp +++ b/common/dataStructures/TapeDrive.hpp @@ -92,9 +92,9 @@ struct TapeDrive { std::optional shutdownTime; MountType mountType; - DriveStatus driveStatus; - bool desiredUp; - bool desiredForceDown; + DriveStatus driveStatus = DriveStatus::Unknown; + bool desiredUp = false; + bool desiredForceDown = false; std::optional reasonUpDown; std::optional currentVid; @@ -102,7 +102,7 @@ struct TapeDrive { std::optional currentPriority; std::optional currentActivity; std::optional currentTapePool; - MountType nextMountType; // defaults to NO_MOUNT. This can't be optional, as we have a NOT nullptr constraint in the DB. + MountType nextMountType = MountType::NoMount; // defaults to NO_MOUNT. This can't be optional, as we have a NOT nullptr constraint in the DB. std::optional nextVid; std::optional nextTapePool; std::optional nextPriority; diff --git a/common/dataStructures/TapeLog.cpp b/common/dataStructures/TapeLog.cpp index cc20247716..85788fc334 100644 --- a/common/dataStructures/TapeLog.cpp +++ b/common/dataStructures/TapeLog.cpp @@ -24,8 +24,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -TapeLog::TapeLog(): - time(0) {} +TapeLog::TapeLog() {} //------------------------------------------------------------------------------ // operator== diff --git a/common/dataStructures/TapeLog.hpp b/common/dataStructures/TapeLog.hpp index 9147f478fc..18b163fdc1 100644 --- a/common/dataStructures/TapeLog.hpp +++ b/common/dataStructures/TapeLog.hpp @@ -38,7 +38,7 @@ struct TapeLog { bool operator!=(const TapeLog &rhs) const; std::string drive; - time_t time; + time_t time = 0; }; // struct TapeLog diff --git a/common/dataStructures/UpdateFileStorageClassRequest.cpp b/common/dataStructures/UpdateFileStorageClassRequest.cpp index 826d597fb5..ad0c947644 100644 --- a/common/dataStructures/UpdateFileStorageClassRequest.cpp +++ b/common/dataStructures/UpdateFileStorageClassRequest.cpp @@ -24,8 +24,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -UpdateFileStorageClassRequest::UpdateFileStorageClassRequest(): - archiveFileID(0) {} +UpdateFileStorageClassRequest::UpdateFileStorageClassRequest() {} //------------------------------------------------------------------------------ // operator== diff --git a/common/dataStructures/UpdateFileStorageClassRequest.hpp b/common/dataStructures/UpdateFileStorageClassRequest.hpp index c08a8f3533..a902b19acc 100644 --- a/common/dataStructures/UpdateFileStorageClassRequest.hpp +++ b/common/dataStructures/UpdateFileStorageClassRequest.hpp @@ -28,8 +28,8 @@ namespace cta::common::dataStructures { /** - * This struct holds all the command line parameters of a CTA - * UpdateFileStorageClass command + * This struct holds all the command line parameters of a CTA + * UpdateFileStorageClass command */ struct UpdateFileStorageClassRequest { @@ -40,7 +40,7 @@ struct UpdateFileStorageClassRequest { bool operator!=(const UpdateFileStorageClassRequest &rhs) const; RequesterIdentity requester; - uint64_t archiveFileID; + uint64_t archiveFileID = 0; std::string storageClass; DiskFileInfo diskFileInfo; diff --git a/common/dataStructures/WriteTestResult.cpp b/common/dataStructures/WriteTestResult.cpp index 33feb13e77..7b36a2549d 100644 --- a/common/dataStructures/WriteTestResult.cpp +++ b/common/dataStructures/WriteTestResult.cpp @@ -24,11 +24,7 @@ namespace cta::common::dataStructures { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -WriteTestResult::WriteTestResult(): - noOfFilesWritten(0), - totalBytesWritten(0), - totalFilesWritten(0), - totalTimeInSeconds(0) {} +WriteTestResult::WriteTestResult() {} //------------------------------------------------------------------------------ // operator== diff --git a/common/dataStructures/WriteTestResult.hpp b/common/dataStructures/WriteTestResult.hpp index 0491c85628..a9e150b0f2 100644 --- a/common/dataStructures/WriteTestResult.hpp +++ b/common/dataStructures/WriteTestResult.hpp @@ -25,7 +25,7 @@ namespace cta::common::dataStructures { /** - * This is the result of a write test operation + * This is the result of a write test operation */ struct WriteTestResult { @@ -37,12 +37,12 @@ struct WriteTestResult { std::string driveName; std::string vid; - uint64_t noOfFilesWritten; + uint64_t noOfFilesWritten = 0; std::map errors; std::map> checksums; - uint64_t totalBytesWritten; - uint64_t totalFilesWritten; - uint64_t totalTimeInSeconds; + uint64_t totalBytesWritten = 0; + uint64_t totalFilesWritten = 0; + uint64_t totalTimeInSeconds = 0; }; // struct WriteTestResult diff --git a/common/exception/Backtrace.cpp b/common/exception/Backtrace.cpp index 667b9ec620..47fd819679 100644 --- a/common/exception/Backtrace.cpp +++ b/common/exception/Backtrace.cpp @@ -113,7 +113,7 @@ namespace cta { } #endif // COLLECTEXTRABACKTRACEINFOS -cta::exception::Backtrace::Backtrace(bool fake): m_trace() { +cta::exception::Backtrace::Backtrace(bool fake) { if (fake) return; void * array[200]; g_lock.lock(); diff --git a/common/exception/Exception.cpp b/common/exception/Exception.cpp index 34b2d07253..de321a48d3 100644 --- a/common/exception/Exception.cpp +++ b/common/exception/Exception.cpp @@ -22,18 +22,17 @@ namespace cta::exception { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -Exception::Exception(std::string_view context, const bool embedBacktrace) : - m_backtrace(!embedBacktrace) { +Exception::Exception(std::string_view context, const bool embedBacktrace) : m_backtrace(!embedBacktrace) { m_message << context; } //------------------------------------------------------------------------------ // copy constructor //------------------------------------------------------------------------------ -Exception::Exception(const Exception& rhs) : std::exception() { - m_message << rhs.m_message.str(); - m_backtrace = rhs.m_backtrace; -} +Exception::Exception(const Exception& rhs) + : std::exception(), + m_message(rhs.m_message.str()), + m_backtrace(rhs.m_backtrace) {} //------------------------------------------------------------------------------ // assignment constructor @@ -61,4 +60,4 @@ void Exception::setWhat(std::string_view what) { getMessage() << what; } -} // namespace cta::exception::Exception +} // namespace cta::exception diff --git a/common/log/Logger.cpp b/common/log/Logger.cpp index 65f069e8a4..c6d3b06446 100644 --- a/common/log/Logger.cpp +++ b/common/log/Logger.cpp @@ -33,8 +33,7 @@ namespace cta::log { // constructor //------------------------------------------------------------------------------ Logger::Logger(std::string_view hostName, std::string_view programName, int logMask) : - m_hostName(hostName), m_programName(programName), m_logMask(logMask), - m_priorityToText(generatePriorityToTextMap()) { } + m_hostName(hostName), m_programName(programName), m_logMask(logMask) { } //------------------------------------------------------------------------------ // destructor @@ -98,8 +97,7 @@ std::string Logger::cleanString(std::string_view s, bool replaceUnderscores) { //------------------------------------------------------------------------------ // generatePriorityToTextMap //------------------------------------------------------------------------------ -std::map - Logger::generatePriorityToTextMap() { +std::map Logger::generatePriorityToTextMap() { return PriorityMaps::c_priorityToTextMap; } diff --git a/common/log/Logger.hpp b/common/log/Logger.hpp index 1d4dc90e97..c9dbb8aefa 100644 --- a/common/log/Logger.hpp +++ b/common/log/Logger.hpp @@ -229,7 +229,7 @@ protected: /** * Map from syslog integer priority to textual representation */ - const std::map m_priorityToText; + const std::map m_priorityToText = generatePriorityToTextMap(); /** * Map from the possible string values of the LogMask parameters and their equivalent syslog priorities diff --git a/common/threading/ChildProcess.hpp b/common/threading/ChildProcess.hpp index 062f321b9e..5d8b4eb7d5 100644 --- a/common/threading/ChildProcess.hpp +++ b/common/threading/ChildProcess.hpp @@ -30,7 +30,7 @@ namespace cta::threading { class ChildProcess { public: /** - * Helper functor for child to clean up unneeded parent resources + * Helper functor for child to clean up unneeded parent resources * after forking. */ class Cleanup { @@ -46,20 +46,20 @@ namespace cta::threading { explicit ProcessStillRunning(const std::string& what = "Process still running"): cta::exception::Exception::Exception(what) {} }; - + class ProcessNeverStarted : public exception::Exception { public: explicit ProcessNeverStarted(const std::string& what = "Process never started"): cta::exception::Exception::Exception(what) {} }; - + class ProcessWasKilled : public exception::Exception { public: explicit ProcessWasKilled(const std::string& what = "Process was killed"): cta::exception::Exception::Exception(what) {} }; - - ChildProcess() : m_started(false), m_finished(false), m_exited(false), m_wasKilled(false), m_exitCode(0) {} + + ChildProcess() = default; /* Clean up leftover child processes (hopefully not useful) */ virtual ~ChildProcess() { try { @@ -80,18 +80,18 @@ namespace cta::threading { private: pid_t m_pid; /** Was the process started? */ - bool m_started; + bool m_started = false; /** As the process finished? */ - bool m_finished; + bool m_finished = false; /** Did the process exit cleanly? */ - bool m_exited; + bool m_exited = false; /** Was the process killed? */ - bool m_wasKilled; - int m_exitCode; + bool m_wasKilled= false; + int m_exitCode = 0; /** The function actually being run in the child process. The value returned * by run() will be the exit code of the process (if we get that far) */ virtual int run() = 0; void parseStatus(int status); }; - + } // namespace cta::threading diff --git a/common/threading/Daemon.cpp b/common/threading/Daemon.cpp index e12f6da5d4..e7fb8b298f 100644 --- a/common/threading/Daemon.cpp +++ b/common/threading/Daemon.cpp @@ -29,9 +29,7 @@ // constructor //------------------------------------------------------------------------------ cta::server::Daemon::Daemon(cta::log::Logger &log) noexcept : - m_log(log), - m_foreground(false), - m_commandLineHasBeenParsed(false) { + m_log(log) { } //------------------------------------------------------------------------------ diff --git a/common/threading/Daemon.hpp b/common/threading/Daemon.hpp index 034664433d..497807fa4c 100644 --- a/common/threading/Daemon.hpp +++ b/common/threading/Daemon.hpp @@ -87,12 +87,12 @@ private: * Flag indicating whether the server should run in foreground or background * mode. */ - bool m_foreground; + bool m_foreground = false; /** * True if the command-line has been parsed. */ - bool m_commandLineHasBeenParsed; + bool m_commandLineHasBeenParsed = false; }; // class Daemon diff --git a/common/threading/Thread.hpp b/common/threading/Thread.hpp index 2022bd65fb..327176476c 100644 --- a/common/threading/Thread.hpp +++ b/common/threading/Thread.hpp @@ -39,7 +39,7 @@ CTA_GENERATE_EXCEPTION_CLASS(UncaughtExceptionInThread); */ class Thread { public: - Thread(): m_hadException(false), m_what(""), m_started(false) {} + Thread() = default; explicit Thread(std::optional stackSize): m_hadException(false), m_what(""), m_started(false), m_stackSize(stackSize) {} virtual ~Thread() = default; @@ -50,11 +50,11 @@ protected: virtual void run () = 0; private: pthread_t m_thread; - bool m_hadException; + bool m_hadException = false; std::string m_what; std::string m_type; static void * pthread_runner (void * arg); - bool m_started; + bool m_started = false; std::optional m_stackSize; }; diff --git a/disk/DiskFile.cpp b/disk/DiskFile.cpp index 9b94977d3c..600fcf9fde 100644 --- a/disk/DiskFile.cpp +++ b/disk/DiskFile.cpp @@ -27,11 +27,7 @@ namespace cta::disk { -DiskFileFactory::DiskFileFactory(uint16_t xrootTimeout) - : m_NoURLLocalFile("^(localhost:|)(/.*)$"), - m_URLLocalFile("^file://(.*)$"), - m_URLXrootFile("^(root://.*)$"), - m_xrootTimeout(xrootTimeout) {} +DiskFileFactory::DiskFileFactory(uint16_t xrootTimeout) : m_xrootTimeout(xrootTimeout) {} ReadFile* DiskFileFactory::createReadFile(const std::string& path) { std::vector regexResult; @@ -111,7 +107,7 @@ LocalReadFile::~LocalReadFile() noexcept { //============================================================================== // LOCAL WRITE FILE //============================================================================== -LocalWriteFile::LocalWriteFile(const std::string& path) : m_closeTried(false) { +LocalWriteFile::LocalWriteFile(const std::string& path) { // For local files, we truncate the file like for RFIO m_fd = ::open64((char*) path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666); m_URL = "file://"; @@ -222,9 +218,7 @@ XrootBaseWriteFile::~XrootBaseWriteFile() noexcept { //============================================================================== // AsyncDiskFileRemover FACTORY //============================================================================== -AsyncDiskFileRemoverFactory::AsyncDiskFileRemoverFactory() - : m_URLLocalFile("^file://(.*)$"), - m_URLXrootdFile("^(root://.*)$") {} +AsyncDiskFileRemoverFactory::AsyncDiskFileRemoverFactory() {} AsyncDiskFileRemover* AsyncDiskFileRemoverFactory::createAsyncDiskFileRemover(const std::string& path) { // URL path parsing @@ -319,7 +313,7 @@ void AsyncLocalDiskFileRemover::wait() { //============================================================================== // DIRECTORY FACTORY //============================================================================== -DirectoryFactory::DirectoryFactory() : m_URLLocalDirectory("^file://(.*)$"), m_URLXrootDirectory("^(root://.*)$") {} +DirectoryFactory::DirectoryFactory() {} Directory* DirectoryFactory::createDirectory(const std::string& path) { // URL path parsing diff --git a/disk/DiskFile.hpp b/disk/DiskFile.hpp index 753ad3fe24..55916f1a43 100644 --- a/disk/DiskFile.hpp +++ b/disk/DiskFile.hpp @@ -52,9 +52,9 @@ namespace cta::disk { ReadFile * createReadFile(const std::string & path); WriteFile * createWriteFile(const std::string & path); private: - Regex m_NoURLLocalFile; - Regex m_URLLocalFile; - Regex m_URLXrootFile; + Regex m_NoURLLocalFile{"^(localhost:|)(/.*)$"}; + Regex m_URLLocalFile{"^file://(.*)$"}; + Regex m_URLXrootFile{"^(root://.*)$"}; const uint16_t m_xrootTimeout; }; @@ -145,8 +145,8 @@ namespace cta::disk { AsyncDiskFileRemoverFactory(); AsyncDiskFileRemover * createAsyncDiskFileRemover(const std::string &path); private: - Regex m_URLLocalFile; - Regex m_URLXrootdFile; + Regex m_URLLocalFile{"^file://(.*)$"}; + Regex m_URLXrootdFile{"^(root://.*)$"}; }; class DiskFileRemover{ @@ -176,8 +176,8 @@ namespace cta::disk { Directory * createDirectory(const std::string &path); private: - Regex m_URLLocalDirectory; - Regex m_URLXrootDirectory; + Regex m_URLLocalDirectory{"^file://(.*)$"}; + Regex m_URLXrootDirectory{"^(root://.*)$"}; }; diff --git a/disk/DiskFileImplementations.hpp b/disk/DiskFileImplementations.hpp index ca96df2956..7b6372f858 100644 --- a/disk/DiskFileImplementations.hpp +++ b/disk/DiskFileImplementations.hpp @@ -28,10 +28,10 @@ namespace cta::disk { /** * Namespace managing the reading and writing of files to and from disk. */ - + //Forward declarations class XRootdDiskFileRemover; - + //============================================================================== // LOCAL FILES //============================================================================== @@ -44,7 +44,7 @@ namespace cta::disk { private: int m_fd; }; - + class LocalWriteFile: public WriteFile { public: explicit LocalWriteFile(const std::string& path); @@ -53,12 +53,12 @@ namespace cta::disk { ~LocalWriteFile() noexcept final; private: int m_fd; - bool m_closeTried; + bool m_closeTried = false; }; - + //============================================================================== // XROOT FILES - //============================================================================== + //============================================================================== class XrootBaseReadFile: public ReadFile { public: explicit XrootBaseReadFile(uint16_t timeout) : m_timeout(timeout) {} @@ -73,15 +73,15 @@ namespace cta::disk { mutable uint64_t m_readPosition; const uint16_t m_timeout; }; - + class XrootReadFile: public XrootBaseReadFile { public: XrootReadFile(const std::string &xrootUrl, uint16_t timeout = 0); }; - + class XrootBaseWriteFile: public WriteFile { public: - explicit XrootBaseWriteFile(uint16_t timeout) : m_writePosition(0), m_timeout(timeout), m_closeTried(false) {} + explicit XrootBaseWriteFile(uint16_t timeout) : m_timeout(timeout) {} void write(const void *data, const size_t size) final; void close() final; ~XrootBaseWriteFile() noexcept override; @@ -89,11 +89,11 @@ namespace cta::disk { // Access to parent's protected member... void setURL(const std::string & v) { m_URL = v; } XrdCl::File m_xrootFile; - uint64_t m_writePosition; + uint64_t m_writePosition = 0; const uint16_t m_timeout; - bool m_closeTried; + bool m_closeTried = false; }; - + class XrootWriteFile: public XrootBaseWriteFile { public: XrootWriteFile(const std::string &xrootUrl, uint16_t timeout = 0); @@ -102,7 +102,7 @@ namespace cta::disk { //============================================================================== // LocalDisk Removers //============================================================================== - + /** * This class allows to delete a file from a local disk */ @@ -191,10 +191,10 @@ namespace cta::disk { void mkdir() override; bool exist() override; std::set getFilesName() override; - void rmdir() override; - private: + void rmdir() override; + private: XrdCl::FileSystem m_xrootFileSystem; std::string m_truncatedDirectoryURL; // root://.../ part of the path is removed - const uint16_t c_xrootTimeout = 15; + const uint16_t c_xrootTimeout = 15; }; } // namespace cta::disk diff --git a/frontend/common/DriveLsResponseStream.cpp b/frontend/common/DriveLsResponseStream.cpp index 1d7708825e..15c7f3ed6e 100644 --- a/frontend/common/DriveLsResponseStream.cpp +++ b/frontend/common/DriveLsResponseStream.cpp @@ -29,8 +29,7 @@ DriveLsResponseStream::DriveLsResponseStream(cta::catalogue::Catalogue& catalogu const admin::AdminCmd& adminCmd, cta::log::LogContext& lc) : CtaAdminResponseStream(catalogue, scheduler, instanceName), - m_lc(lc), - m_listAllDrives(false) { + m_lc(lc) { using namespace cta::admin; cta::frontend::AdminCmdOptions request(adminCmd); diff --git a/frontend/common/DriveLsResponseStream.hpp b/frontend/common/DriveLsResponseStream.hpp index f94b7aeb99..a6f2b462e3 100644 --- a/frontend/common/DriveLsResponseStream.hpp +++ b/frontend/common/DriveLsResponseStream.hpp @@ -43,8 +43,8 @@ private: std::list m_tapeDrives; std::unordered_map> m_tapeDriveNameConfigMap; - bool m_listAllDrives; + bool m_listAllDrives = false; std::optional m_schedulerBackendName; }; -} // namespace cta::frontend \ No newline at end of file +} // namespace cta::frontend diff --git a/frontend/common/FailedRequestLsResponseStream.cpp b/frontend/common/FailedRequestLsResponseStream.cpp index 35c7baa51d..75395971b3 100644 --- a/frontend/common/FailedRequestLsResponseStream.cpp +++ b/frontend/common/FailedRequestLsResponseStream.cpp @@ -32,9 +32,7 @@ FailedRequestLsResponseStream::FailedRequestLsResponseStream(cta::catalogue::Cat cta::log::LogContext& lc) : CtaAdminResponseStream(catalogue, scheduler, instanceName), m_schedDb(schedDb), - m_lc(lc), - m_isSummary(false), - m_isLogEntries(false) { + m_lc(lc) { using namespace cta::admin; cta::frontend::AdminCmdOptions request(adminCmd); @@ -211,4 +209,4 @@ cta::xrd::Data FailedRequestLsResponseStream::next() { return data; } -} // namespace cta::frontend \ No newline at end of file +} // namespace cta::frontend diff --git a/frontend/common/FailedRequestLsResponseStream.hpp b/frontend/common/FailedRequestLsResponseStream.hpp index b00b18be26..e1c0862cd1 100644 --- a/frontend/common/FailedRequestLsResponseStream.hpp +++ b/frontend/common/FailedRequestLsResponseStream.hpp @@ -41,8 +41,8 @@ private: cta::log::LogContext& m_lc; // Configuration options - bool m_isSummary; - bool m_isLogEntries; + bool m_isSummary = false; + bool m_isLogEntries = false; std::optional m_schedulerBackendName; // Data storage @@ -54,4 +54,4 @@ private: void collectSummaryData(bool hasArchive, bool hasRetrieve); }; -} // namespace cta::frontend \ No newline at end of file +} // namespace cta::frontend diff --git a/frontend/common/FrontendService.cpp b/frontend/common/FrontendService.cpp index dd078e438d..08e43933a5 100644 --- a/frontend/common/FrontendService.cpp +++ b/frontend/common/FrontendService.cpp @@ -37,7 +37,7 @@ namespace cta::frontend { -FrontendService::FrontendService(const std::string& configFilename) : m_archiveFileMaxSize(0) { +FrontendService::FrontendService(const std::string& configFilename) { int logToStdout = 0; int logtoFile = 0; std::string logFilePath = ""; diff --git a/frontend/common/FrontendService.hpp b/frontend/common/FrontendService.hpp index 9fca64c4aa..3503e4b126 100644 --- a/frontend/common/FrontendService.hpp +++ b/frontend/common/FrontendService.hpp @@ -212,7 +212,7 @@ private: std::optional m_retrieveQueueCacheMaxAgeSecs; //!< Option to override the retrieve queue timeout value in the scheduler DB std::string m_catalogue_conn_string; //!< The catalogue connection string (without the password) std::string m_schedulerBackendName; //!< value of cta.schedulerdb.scheduler_backend_name in the CTA frontend configuration file - uint64_t m_archiveFileMaxSize; //!< Maximum allowed file size for archive requests + uint64_t m_archiveFileMaxSize = 0; //!< Maximum allowed file size for archive requests bool m_zeroLengthFilesForbidden; //!< Flag to explicitly reject the 0-length files by default std::vector m_zeroLengthFilesForbidden_voExceptions; //!< If 0-length files are rejected by default, do not apply check to these VOs std::optional m_repackBufferURL; //!< The repack buffer URL diff --git a/frontend/grpc/ClientNegotiationRequestHandler.cpp b/frontend/grpc/ClientNegotiationRequestHandler.cpp index a51c7fa610..055a33fd11 100644 --- a/frontend/grpc/ClientNegotiationRequestHandler.cpp +++ b/frontend/grpc/ClientNegotiationRequestHandler.cpp @@ -14,7 +14,7 @@ * granted to it by virtue of its status as an Intergovernmental Organization or * submit itself to any jurisdiction. */ - + #include "ClientNegotiationRequestHandler.hpp" #include "common/log/LogContext.hpp" #include "common/exception/Exception.hpp" @@ -28,21 +28,20 @@ cta::frontend::grpc::client::NegotiationRequestHandler::NegotiationRequestHandle m_stub(stub), m_completionQueue(completionQueue), m_strSpn(strSpn), - m_tag(this), - m_streamState(StreamState::NEW) { + m_tag(this) { // Get KRB5 principal name for the given service m_gssNameSpn = gssSpn(m_strSpn); } void cta::frontend::grpc::client::NegotiationRequestHandler::logGSSErrors(const std::string& strContext, OM_uint32 gssCode, int iType) { - + log::LogContext lc(m_log); log::ScopedParamContainer params(lc); std::ostringstream osMsgScopeParam; OM_uint32 gssMinStat; gss_buffer_desc gssMsg; OM_uint32 gssMsgCtx = 0; - + params.add("tag", m_tag); /* * Because gss_display_status() only displays one status code at a time, @@ -57,7 +56,7 @@ void cta::frontend::grpc::client::NegotiationRequestHandler::logGSSErrors(const osMsgScopeParam.str(""); // reset ostringstream gss_release_buffer(&gssMinStat, &gssMsg); } while(gssMsgCtx); - + lc.log(cta::log::ERR, strContext); } @@ -86,9 +85,9 @@ bool cta::frontend::grpc::client::NegotiationRequestHandler::next(const bool bOk bool bNext = false; log::LogContext lc(m_log); std::string strErrorMsg; - + const uint8_t* pChallengeData = nullptr; - + // Check the state and report an error if(!bOk) { switch (m_streamState) { @@ -110,7 +109,7 @@ bool cta::frontend::grpc::client::NegotiationRequestHandler::next(const bool bOk { log::ScopedParamContainer params(lc); params.add("tag", m_tag); - lc.log(cta::log::INFO, "In grpc::client::NegotiationRequestHandler::next(): Request processing finished."); + lc.log(cta::log::INFO, "In grpc::client::NegotiationRequestHandler::next(): Request processing finished."); } break; default: @@ -128,7 +127,7 @@ bool cta::frontend::grpc::client::NegotiationRequestHandler::next(const bool bOk } // else everything is OK bNext = true; - + switch (m_streamState) { case StreamState::NEW: // CMD: prepare Negotiate stream @@ -152,10 +151,10 @@ bool cta::frontend::grpc::client::NegotiationRequestHandler::next(const bool bOk m_streamState = StreamState::FINISH; m_uprwNegotiation->WritesDone(m_tag); } else { - pChallengeData = reinterpret_cast(m_response.challenge().c_str()); + pChallengeData = reinterpret_cast(m_response.challenge().c_str()); m_gssRecvToken.length = m_response.challenge().size(); m_gssRecvToken.value = const_cast(reinterpret_cast(pChallengeData)); - + m_gssMajStat = gss_init_sec_context( // &m_gssMinStat, // minor_status m_gssCred, // claimant_cred_handle @@ -168,11 +167,11 @@ bool cta::frontend::grpc::client::NegotiationRequestHandler::next(const bool bOk // GSS_C_NO_BUFFER, // input token &m_gssRecvToken, // input token nullptr, // actual_mech_type - &m_gssSendToken, // output token + &m_gssSendToken, // output token nullptr, // ret_flags nullptr // time_req ); - + switch (m_gssMajStat) { // https://www.ietf.org/archive/id/draft-perez-krb-wg-gss-preauth-03.html case GSS_S_CONTINUE_NEEDED: @@ -181,7 +180,7 @@ bool cta::frontend::grpc::client::NegotiationRequestHandler::next(const bool bOk m_request.set_service_principal_name(m_strSpn); gss_release_buffer(&m_gssMinStat, &m_gssSendToken); m_uprwNegotiation->Write(m_request, m_tag); - + break; case GSS_S_COMPLETE: m_streamState = StreamState::FINISH; @@ -225,7 +224,7 @@ bool cta::frontend::grpc::client::NegotiationRequestHandler::next(const bool bOk gss_release_cred(&m_gssMinStat, &m_gssCred); gss_release_buffer(&m_gssMinStat, &m_gssSendToken); gss_release_name(&m_gssMinStat, &m_gssNameSpn); - + switch(m_grpcStatus.error_code()) { case ::grpc::OK: { @@ -255,7 +254,7 @@ bool cta::frontend::grpc::client::NegotiationRequestHandler::next(const bool bOk // no default break; } - + return bNext; } diff --git a/frontend/grpc/ClientNegotiationRequestHandler.hpp b/frontend/grpc/ClientNegotiationRequestHandler.hpp index 2ad5cc1689..f43589e06d 100644 --- a/frontend/grpc/ClientNegotiationRequestHandler.hpp +++ b/frontend/grpc/ClientNegotiationRequestHandler.hpp @@ -14,7 +14,7 @@ * granted to it by virtue of its status as an Intergovernmental Organization or * submit itself to any jurisdiction. */ - + #pragma once #include "IHandler.hpp" @@ -51,16 +51,16 @@ private: READ, FINISH }; - + cta::log::Logger& m_log; cta::xrd::Negotiation::Stub& m_stub; ::grpc::CompletionQueue& m_completionQueue; const std::string& m_strSpn; cta::frontend::grpc::request::Tag m_tag; - - StreamState m_streamState; - - + + StreamState m_streamState = StreamState::NEW; + + // Context for the rpc, allowing to tweak aspects of it such as the use // of compression, authentication, as well as to send metadata back to the // client. @@ -90,7 +90,7 @@ private: void logGSSErrors(const std::string& strContext, OM_uint32 gssCode, int iType); gss_name_t gssSpn(const std::string& strSpn); - + }; } // namespace cta::frontend::grpc::client diff --git a/frontend/grpc/ServerNegotiationRequestHandler.cpp b/frontend/grpc/ServerNegotiationRequestHandler.cpp index 515e1d4268..b6cefc111d 100644 --- a/frontend/grpc/ServerNegotiationRequestHandler.cpp +++ b/frontend/grpc/ServerNegotiationRequestHandler.cpp @@ -33,8 +33,6 @@ cta::frontend::grpc::server::NegotiationRequestHandler::NegotiationRequestHandle m_ctaNegotiationSvc(ctaNegotiationSvc), m_strKeytab(strKeytab), m_strService(strService), - m_streamState(StreamState::NEW), - m_gssCtx(GSS_C_NO_CONTEXT), m_rwNegotiation(&m_ctx) {} cta::frontend::grpc::server::NegotiationRequestHandler::~NegotiationRequestHandler() { diff --git a/frontend/grpc/ServerNegotiationRequestHandler.hpp b/frontend/grpc/ServerNegotiationRequestHandler.hpp index 8aca92bc8a..c1dfb0fbc8 100644 --- a/frontend/grpc/ServerNegotiationRequestHandler.hpp +++ b/frontend/grpc/ServerNegotiationRequestHandler.hpp @@ -62,8 +62,8 @@ private: cta::xrd::Negotiation::AsyncService& m_ctaNegotiationSvc; std::string m_strKeytab; const std::string m_strService; - StreamState m_streamState; - gss_ctx_id_t m_gssCtx; + StreamState m_streamState = StreamState::NEW; + gss_ctx_id_t m_gssCtx = GSS_C_NO_CONTEXT; gss_cred_id_t m_serverCreds = {GSS_C_NO_CREDENTIAL}; /* * Context for the rpc, allowing to tweak aspects of it such as the use diff --git a/frontend/grpc/callback_api/CtaAdminClientReadReactor.hpp b/frontend/grpc/callback_api/CtaAdminClientReadReactor.hpp index 42d847529f..97c35b517b 100644 --- a/frontend/grpc/callback_api/CtaAdminClientReadReactor.hpp +++ b/frontend/grpc/callback_api/CtaAdminClientReadReactor.hpp @@ -242,10 +242,9 @@ public: } // if (ok) } - CtaAdminClientReadReactor(cta::xrd::CtaRpcStream::Stub* client_stub, const cta::admin::CtaAdminParsedCmd& parsedCmd) { + CtaAdminClientReadReactor(cta::xrd::CtaRpcStream::Stub* client_stub, const cta::admin::CtaAdminParsedCmd& parsedCmd) : m_isJson(parsedCmd.isJson()) { const auto& request = parsedCmd.getRequest(); client_stub->async()->GenericAdminStream(&m_context, &request, this); - m_isJson = parsedCmd.isJson(); StartRead(&m_response); // where to store the received response? StartCall(); // activate the RPC! } diff --git a/frontend/grpc/callback_api/CtaAdminServerWriteReactor.cpp b/frontend/grpc/callback_api/CtaAdminServerWriteReactor.cpp index bf0303c29a..85efe281ec 100644 --- a/frontend/grpc/callback_api/CtaAdminServerWriteReactor.cpp +++ b/frontend/grpc/callback_api/CtaAdminServerWriteReactor.cpp @@ -52,8 +52,7 @@ CtaAdminServerWriteReactor::CtaAdminServerWriteReactor(cta::catalogue::Catalogue const std::string& instanceName, std::unique_ptr stream, cta::admin::HeaderType headerType) - : m_isHeaderSent(false), - m_schedulerBackendName(scheduler.getSchedulerBackendName()), + : m_schedulerBackendName(scheduler.getSchedulerBackendName()), m_instanceName(instanceName), m_stream(std::move(stream)), m_headerType(headerType) { @@ -61,4 +60,4 @@ CtaAdminServerWriteReactor::CtaAdminServerWriteReactor(cta::catalogue::Catalogue NextWrite(); } } -} // namespace cta::frontend::grpc \ No newline at end of file +} // namespace cta::frontend::grpc diff --git a/frontend/grpc/callback_api/CtaAdminServerWriteReactor.hpp b/frontend/grpc/callback_api/CtaAdminServerWriteReactor.hpp index 6bcd743946..bcadc3855f 100644 --- a/frontend/grpc/callback_api/CtaAdminServerWriteReactor.hpp +++ b/frontend/grpc/callback_api/CtaAdminServerWriteReactor.hpp @@ -25,11 +25,11 @@ public: void OnDone() override; virtual void NextWrite(); // this needs to be virtual for the Version command only protected: // so that the child classes can access those as if they were theirs - bool m_isHeaderSent; // or could be a static variable in the function NextWrite() + bool m_isHeaderSent = false; // or could be a static variable in the function NextWrite() cta::xrd::StreamResponse m_response; std::optional m_schedulerBackendName; std::string m_instanceName; std::unique_ptr m_stream; cta::admin::HeaderType m_headerType; }; -} // namespace cta::frontend::grpc \ No newline at end of file +} // namespace cta::frontend::grpc diff --git a/frontend/grpc/callback_api/ServerVersion.hpp b/frontend/grpc/callback_api/ServerVersion.hpp index 09ba5d379b..6ca0c352e1 100644 --- a/frontend/grpc/callback_api/ServerVersion.hpp +++ b/frontend/grpc/callback_api/ServerVersion.hpp @@ -23,7 +23,7 @@ public: void NextWrite() override; private: - bool m_isVersionSent; + bool m_isVersionSent = false; frontend::Version m_client_versions; frontend::Version m_server_versions; std::string m_catalogue_conn_string; @@ -37,7 +37,6 @@ VersionWriteReactor::VersionWriteReactor(cta::catalogue::Catalogue& catalogue, const std::string& catalogueConnString, const cta::xrd::Request* request) : CtaAdminServerWriteReactor(catalogue, scheduler, instanceName, nullptr, cta::admin::HeaderType::VERSION_CMD), - m_isVersionSent(false), m_catalogue_conn_string(catalogueConnString), m_catalogue_version(catalogue.Schema()->getSchemaVersion().getSchemaVersion()), m_is_upgrading(catalogue.Schema()->getSchemaVersion().getStatus() == @@ -89,4 +88,4 @@ void VersionWriteReactor::NextWrite() { Finish(::grpc::Status::OK); } } -} // namespace cta::frontend::grpc \ No newline at end of file +} // namespace cta::frontend::grpc diff --git a/mediachanger/DebugBuf.cpp b/mediachanger/DebugBuf.cpp index 2277101199..6f37132689 100644 --- a/mediachanger/DebugBuf.cpp +++ b/mediachanger/DebugBuf.cpp @@ -20,9 +20,7 @@ //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -cta::mediachanger::DebugBuf::DebugBuf(std::ostream &os): - m_debug(false), m_os(os), m_writePreamble(true) { -} +cta::mediachanger::DebugBuf::DebugBuf(std::ostream &os) : m_os(os) {} //------------------------------------------------------------------------------ // setDebug diff --git a/mediachanger/DebugBuf.hpp b/mediachanger/DebugBuf.hpp index 7f77970f86..082f68fb4c 100644 --- a/mediachanger/DebugBuf.hpp +++ b/mediachanger/DebugBuf.hpp @@ -72,7 +72,7 @@ private: /** * True if debug mode is on. */ - bool m_debug; + bool m_debug = false; /** * The output stream to which each debug message-line togther with its @@ -83,7 +83,7 @@ private: /** * True is a preamble should be written. */ - bool m_writePreamble; + bool m_writePreamble = true; }; // class DebugBuf diff --git a/mediachanger/MessageHeader.cpp b/mediachanger/MessageHeader.cpp index 985d629d2b..8c7c072ca0 100644 --- a/mediachanger/MessageHeader.cpp +++ b/mediachanger/MessageHeader.cpp @@ -22,10 +22,6 @@ namespace cta::mediachanger { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -MessageHeader::MessageHeader(): - magic(0), - reqType(0), - lenOrStatus(0) { -} +MessageHeader::MessageHeader() {} } // namespace cta::mediachanger diff --git a/mediachanger/MessageHeader.hpp b/mediachanger/MessageHeader.hpp index 5741549904..ea0e8733e6 100644 --- a/mediachanger/MessageHeader.hpp +++ b/mediachanger/MessageHeader.hpp @@ -28,12 +28,12 @@ struct MessageHeader { /** * The magic number of the message. */ - uint32_t magic; + uint32_t magic = 0; /** * The request type of the message. */ - uint32_t reqType; + uint32_t reqType = 0; /** * The length of the message body in bytes if this is the header of any @@ -41,7 +41,7 @@ struct MessageHeader { * an acknowledge message then there is no message body and this field is * used to pass the status of the acknowledge. */ - uint32_t lenOrStatus; + uint32_t lenOrStatus = 0; /** * Constructor. diff --git a/mediachanger/RmcMountMsgBody.cpp b/mediachanger/RmcMountMsgBody.cpp index b86c2c52f7..b606ca4cd7 100644 --- a/mediachanger/RmcMountMsgBody.cpp +++ b/mediachanger/RmcMountMsgBody.cpp @@ -24,11 +24,7 @@ namespace cta::mediachanger { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -RmcMountMsgBody::RmcMountMsgBody(): - uid(0), - gid(0), - side(0), - drvOrd(0) { +RmcMountMsgBody::RmcMountMsgBody() { memset(unusedLoader, '\0', sizeof(unusedLoader)); memset(vid, '\0', sizeof(vid)); } diff --git a/mediachanger/RmcMountMsgBody.hpp b/mediachanger/RmcMountMsgBody.hpp index c9a2efeeec..b305c132f9 100644 --- a/mediachanger/RmcMountMsgBody.hpp +++ b/mediachanger/RmcMountMsgBody.hpp @@ -27,12 +27,12 @@ namespace cta::mediachanger { * The body of an RMC_SCSI_MOUNT message */ struct RmcMountMsgBody { - uint32_t uid; - uint32_t gid; + uint32_t uid = 0; + uint32_t gid = 0; char unusedLoader[1]; // Should always be set to the empty string char vid[CA_MAXVIDLEN+1]; - uint16_t side; - uint16_t drvOrd; + uint16_t side = 0; + uint16_t drvOrd = 0; /** * Constructor diff --git a/mediachanger/RmcUnmountMsgBody.cpp b/mediachanger/RmcUnmountMsgBody.cpp index 5d5109d406..1c82e9c32d 100644 --- a/mediachanger/RmcUnmountMsgBody.cpp +++ b/mediachanger/RmcUnmountMsgBody.cpp @@ -24,11 +24,7 @@ namespace cta::mediachanger { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -RmcUnmountMsgBody::RmcUnmountMsgBody(): - uid(0), - gid(0), - drvOrd(0), - force(0) { +RmcUnmountMsgBody::RmcUnmountMsgBody() { memset(unusedLoader, '\0', sizeof(unusedLoader)); memset(vid, '\0', sizeof(vid)); } diff --git a/mediachanger/RmcUnmountMsgBody.hpp b/mediachanger/RmcUnmountMsgBody.hpp index 16dfd8bf06..c0440de9f2 100644 --- a/mediachanger/RmcUnmountMsgBody.hpp +++ b/mediachanger/RmcUnmountMsgBody.hpp @@ -27,12 +27,12 @@ namespace cta::mediachanger { * The body of an RMC_SCSI_UNMOUNT message */ struct RmcUnmountMsgBody { - uint32_t uid; - uint32_t gid; + uint32_t uid = 0; + uint32_t gid = 0; char unusedLoader[1]; // Should always be set to the emtpy string char vid[CA_MAXVIDLEN+1]; - uint16_t drvOrd; - uint16_t force; + uint16_t drvOrd = 0; + uint16_t force = 0; /** * Constructor diff --git a/objectstore/AgentReference.cpp b/objectstore/AgentReference.cpp index 37ebbbda70..302ac723d3 100644 --- a/objectstore/AgentReference.cpp +++ b/objectstore/AgentReference.cpp @@ -31,7 +31,7 @@ namespace cta::objectstore { std::atomic AgentReference::g_nextAgentId(0); AgentReference::AgentReference(const std::string & clientType, log::Logger &logger) : - m_nextId(0), m_logger(logger) { + m_logger(logger) { std::stringstream aid; // Get time time_t now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); diff --git a/objectstore/AgentReference.hpp b/objectstore/AgentReference.hpp index cfcd352b32..868fa4a1e7 100644 --- a/objectstore/AgentReference.hpp +++ b/objectstore/AgentReference.hpp @@ -100,7 +100,7 @@ public: std::string getAgentAddress() override; private: static std::atomic g_nextAgentId; - std::atomic m_nextId; + std::atomic m_nextId = 0; std::string m_agentAddress; /** @@ -132,7 +132,7 @@ private: AgentOperation op; const std::string & objectAddress; const std::list & objectAddressSet; - std::shared_ptr> promise; + std::shared_ptr> promise = std::make_shared>(); /*** * A mutex ensuring the object will not be released before the promise's result * is fully pushed. diff --git a/objectstore/BackendRados.cpp b/objectstore/BackendRados.cpp index 14ca781b6c..67e01a8f34 100644 --- a/objectstore/BackendRados.cpp +++ b/objectstore/BackendRados.cpp @@ -601,7 +601,7 @@ Backend::AsyncCreator* BackendRados::asyncCreate(const std::string& name, const } BackendRados::AsyncCreator::AsyncCreator(BackendRados& be, const std::string& name, const std::string& value): -m_backend(be), m_name(name), m_value(value), m_job(), m_jobFuture(m_job.get_future()) { +m_backend(be), m_name(name), m_value(value), m_jobFuture(m_job.get_future()) { try { librados::ObjectWriteOperation wop; const bool createExclusive = true; @@ -732,7 +732,7 @@ Backend::AsyncUpdater* BackendRados::asyncUpdate(const std::string & name, std:: } BackendRados::AsyncUpdater::AsyncUpdater(BackendRados& be, const std::string& name, std::function& update): - m_backend(be), m_name(name), m_update(update), m_job(), m_jobFuture(m_job.get_future()) { + m_backend(be), m_name(name), m_update(update), m_jobFuture(m_job.get_future()) { m_updateJob.setParentUpdater(this); // At construction time, we just fire a lock. try { @@ -936,7 +936,7 @@ Backend::AsyncDeleter* BackendRados::asyncDelete(const std::string & name) } BackendRados::AsyncDeleter::AsyncDeleter(BackendRados& be, const std::string& name): - m_backend(be), m_name(name), m_job(), m_jobFuture(m_job.get_future()) { + m_backend(be), m_name(name), m_jobFuture(m_job.get_future()) { // At construction time, we just fire a lock. try { // Rados does not have aio_lock, so we do it in an async. @@ -1001,7 +1001,7 @@ void BackendRados::AsyncDeleter::wait() { } BackendRados::AsyncLockfreeFetcher::AsyncLockfreeFetcher(BackendRados& be, const std::string& name): - m_backend(be), m_name(name), m_job(), m_jobFuture(m_job.get_future()) { + m_backend(be), m_name(name), m_jobFuture(m_job.get_future()) { // At construction, just post the aio poster to the thread pool. m_aioReadPoster.setParentFatcher(this); m_backend.m_jobQueue.push(&m_aioReadPoster); diff --git a/objectstore/BackendRados.hpp b/objectstore/BackendRados.hpp index 95bfd3ed2e..f4fb125859 100644 --- a/objectstore/BackendRados.hpp +++ b/objectstore/BackendRados.hpp @@ -76,13 +76,13 @@ public: public: ~ScopedLock() override; private: - explicit ScopedLock(librados::IoCtx& ioCtx) : m_lockSet(false), m_context(ioCtx), m_lockType(LockType::Shared) {} + explicit ScopedLock(librados::IoCtx& ioCtx) : m_context(ioCtx) {} void set(const std::string & oid, const std::string& clientId, LockType lockType); - bool m_lockSet; + bool m_lockSet = false; librados::IoCtx & m_context; std::string m_clientId; std::string m_oid; - LockType m_lockType; + LockType m_lockType = LockType::Shared; }; static const size_t c_maxBackoff; diff --git a/objectstore/BackendVFS.hpp b/objectstore/BackendVFS.hpp index b04e4d5fd5..f600ac0c81 100644 --- a/objectstore/BackendVFS.hpp +++ b/objectstore/BackendVFS.hpp @@ -83,16 +83,16 @@ class BackendVFS: public Backend { void release() override; ~ScopedLock() override { ScopedLock::release(); } private: - ScopedLock() : m_fdSet(false), m_fd(0) {} + ScopedLock() = default; void set(int fd, std::string_view path) { m_fd = fd; m_fdSet = true; m_path = path; } - bool m_fdSet; + bool m_fdSet = false; std::string m_path; - int m_fd; + int m_fd = 0; }; ScopedLock * lockExclusive(const std::string& name, uint64_t timeout_us = 0) override; diff --git a/objectstore/ObjectOps.hpp b/objectstore/ObjectOps.hpp index 346bdf0b06..82e574f6b5 100644 --- a/objectstore/ObjectOps.hpp +++ b/objectstore/ObjectOps.hpp @@ -82,7 +82,7 @@ class ObjectOpsBase { friend ContainerTraits; friend ContainerTraits; protected: - explicit ObjectOpsBase(Backend& os): m_nameSet(false), m_objectStore(os) { } + explicit ObjectOpsBase(Backend& os): m_objectStore(os) { } virtual ~ObjectOpsBase(); public: ObjectOpsBase(const ObjectOpsBase&) = default; @@ -201,7 +201,7 @@ public: } protected: - bool m_nameSet; + bool m_nameSet = false; std::string m_name; Backend & m_objectStore; serializers::ObjectHeader m_header; @@ -308,11 +308,11 @@ public: CTA_GENERATE_EXCEPTION_CLASS(MissingAddress); protected: - ScopedLock(): m_objectOps(nullptr), m_locked(false) {} + ScopedLock() = default; std::unique_ptr m_lock; - ObjectOpsBase * m_objectOps; + ObjectOpsBase * m_objectOps = nullptr; std::list m_subObjectsOps; - bool m_locked; + bool m_locked = false; void checkNotLocked() { if (m_locked) throw AlreadyLocked("In ScopedLock::checkNotLocked: trying to lock an already locked lock"); diff --git a/objectstore/RepackQueueAlgorithms.hpp b/objectstore/RepackQueueAlgorithms.hpp index e5cc5a5585..0201b4f8f6 100644 --- a/objectstore/RepackQueueAlgorithms.hpp +++ b/objectstore/RepackQueueAlgorithms.hpp @@ -52,8 +52,8 @@ struct ContainerTraits }; struct PoppedElementsSummary; struct PopCriteria { - uint64_t requests; - PopCriteria() : requests(1) {} + uint64_t requests = 1; + PopCriteria() = default; PopCriteria& operator-=(const PoppedElementsSummary&); }; struct PoppedElementsSummary { diff --git a/rdbms/AutoRollback.cpp b/rdbms/AutoRollback.cpp index 19e611762e..daefd99c45 100644 --- a/rdbms/AutoRollback.cpp +++ b/rdbms/AutoRollback.cpp @@ -24,10 +24,7 @@ namespace cta::rdbms { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -AutoRollback::AutoRollback(Conn &conn): - m_cancelled(false), - m_conn(conn) { -} +AutoRollback::AutoRollback(Conn &conn) : m_conn(conn) {} //------------------------------------------------------------------------------ // destructor diff --git a/rdbms/AutoRollback.hpp b/rdbms/AutoRollback.hpp index 3ef703ed37..fc75971a36 100644 --- a/rdbms/AutoRollback.hpp +++ b/rdbms/AutoRollback.hpp @@ -63,9 +63,9 @@ public: private: /** - * True if the automatica rollback has been cancelled. + * True if the automatic rollback has been cancelled. */ - bool m_cancelled; + bool m_cancelled = false; /** * The database connection or nullptr if no rollback should take place. diff --git a/rdbms/ConnPool.cpp b/rdbms/ConnPool.cpp index f365ad92c7..b73c0e44df 100644 --- a/rdbms/ConnPool.cpp +++ b/rdbms/ConnPool.cpp @@ -31,8 +31,7 @@ namespace cta::rdbms { //------------------------------------------------------------------------------ ConnPool::ConnPool(const Login& login, const uint64_t maxNbConns) : m_connFactory(wrapper::ConnFactoryFactory::create(login)), - m_maxNbConns(maxNbConns), - m_nbConnsOnLoan(0) {} + m_maxNbConns(maxNbConns) {} ConnPool::~ConnPool() { resetNbConnsOnLoan(); diff --git a/rdbms/ConnPool.hpp b/rdbms/ConnPool.hpp index 2855489739..de5b1ceb06 100644 --- a/rdbms/ConnPool.hpp +++ b/rdbms/ConnPool.hpp @@ -116,7 +116,7 @@ private: /** * The number of database connections currently on loan. */ - uint64_t m_nbConnsOnLoan; + uint64_t m_nbConnsOnLoan = 0; /** * Mutex used to serialize access to the database connections within the pool. diff --git a/rdbms/wrapper/ColumnNameToIdxAndType.hpp b/rdbms/wrapper/ColumnNameToIdxAndType.hpp index 00a711443d..c0f3097054 100644 --- a/rdbms/wrapper/ColumnNameToIdxAndType.hpp +++ b/rdbms/wrapper/ColumnNameToIdxAndType.hpp @@ -36,19 +36,13 @@ public: /** * The index of the column. */ - int colIdx; + int colIdx = 0; /** * The type of the column as return by the sqlite3_column_type() function * before any type conversion has taken place. */ - int colType; - - /** - * Constructor. Set both member-variables to 0. - */ - IdxAndType(): colIdx(0), colType(0) { - } + int colType = 0; }; /** diff --git a/rdbms/wrapper/OcciColumn.cpp b/rdbms/wrapper/OcciColumn.cpp index c77722be86..2f40bba544 100644 --- a/rdbms/wrapper/OcciColumn.cpp +++ b/rdbms/wrapper/OcciColumn.cpp @@ -25,8 +25,7 @@ namespace cta::rdbms::wrapper { //------------------------------------------------------------------------------ OcciColumn::OcciColumn(const std::string &colName, const size_t nbRows): m_colName(colName), - m_nbRows(nbRows), - m_maxFieldLength(0) { + m_nbRows(nbRows) { m_fieldLengths.reset(new ub2[m_nbRows]); ub2 *fieldLengths = m_fieldLengths.get(); if (nullptr == fieldLengths) { diff --git a/rdbms/wrapper/OcciColumn.hpp b/rdbms/wrapper/OcciColumn.hpp index b861624adc..7e5e77fff1 100644 --- a/rdbms/wrapper/OcciColumn.hpp +++ b/rdbms/wrapper/OcciColumn.hpp @@ -213,7 +213,7 @@ private: /** * The maximum of all the field lengths. */ - ub2 m_maxFieldLength; + ub2 m_maxFieldLength = 0; }; // OcciColumn diff --git a/rdbms/wrapper/OcciConn.cpp b/rdbms/wrapper/OcciConn.cpp index f914e7cc5d..f96513cabb 100644 --- a/rdbms/wrapper/OcciConn.cpp +++ b/rdbms/wrapper/OcciConn.cpp @@ -40,7 +40,6 @@ OcciConn::OcciConn(oracle::occi::Environment* const env, const std::string& dbNamespace) : m_env(env), m_occiConn(conn), - m_autocommitMode(AutocommitMode::AUTOCOMMIT_ON), m_dbNamespace(dbNamespace) { if(nullptr == conn) { throw exception::NullPtrException("The OCCI connection is a nullptr pointer"); diff --git a/rdbms/wrapper/OcciConn.hpp b/rdbms/wrapper/OcciConn.hpp index 138e6229c2..a95f4743d6 100644 --- a/rdbms/wrapper/OcciConn.hpp +++ b/rdbms/wrapper/OcciConn.hpp @@ -244,7 +244,7 @@ private: /** * The autocommit mode of the connection. */ - AutocommitMode m_autocommitMode; + AutocommitMode m_autocommitMode = AutocommitMode::AUTOCOMMIT_ON; /** * Closes the specified OCCI statement. diff --git a/rdbms/wrapper/PostgresRset.cpp b/rdbms/wrapper/PostgresRset.cpp index 0e5b8e0675..f3dde39da8 100644 --- a/rdbms/wrapper/PostgresRset.cpp +++ b/rdbms/wrapper/PostgresRset.cpp @@ -34,9 +34,7 @@ namespace cta::rdbms::wrapper { PostgresRset::PostgresRset(PostgresConn& conn, PostgresStmt& stmt, std::unique_ptr resItr) : m_conn(conn), m_stmt(stmt), - m_resItr(std::move(resItr)), - m_asyncCleared(false), - m_nfetched(0) { + m_resItr(std::move(resItr)) { // assumes statement and connection locks have already been taken if (!m_conn.isAsyncInProgress()) { throw exception::Exception("Async flag not set"); diff --git a/rdbms/wrapper/PostgresRset.hpp b/rdbms/wrapper/PostgresRset.hpp index 3ba3f325e2..dd39246d8a 100644 --- a/rdbms/wrapper/PostgresRset.hpp +++ b/rdbms/wrapper/PostgresRset.hpp @@ -359,12 +359,12 @@ private: * Indicates we have cleared the async in progress flag of the conneciton. * This is to make sure we don't clear it more than once */ - bool m_asyncCleared; + bool m_asyncCleared = false; /** * Number fetched, used for setting the number of affected rows of the statement. */ - uint64_t m_nfetched; + uint64_t m_nfetched = 0; }; // class PostgresRset diff --git a/rdbms/wrapper/PostgresStmt.cpp b/rdbms/wrapper/PostgresStmt.cpp index cc4647a7ca..3b3aa0dc1a 100644 --- a/rdbms/wrapper/PostgresStmt.cpp +++ b/rdbms/wrapper/PostgresStmt.cpp @@ -39,9 +39,7 @@ namespace cta::rdbms::wrapper { //------------------------------------------------------------------------------ PostgresStmt::PostgresStmt(PostgresConn& conn, const std::string& sql) : StmtWrapper(sql), - m_conn(conn), - m_nParams(0), - m_nbAffectedRows(0) { + m_conn(conn) { // connection is rd locked CountAndReformatSqlBinds(sql, m_pgsql, m_nParams); diff --git a/rdbms/wrapper/PostgresStmt.hpp b/rdbms/wrapper/PostgresStmt.hpp index 1cc026cbc7..d23c952416 100644 --- a/rdbms/wrapper/PostgresStmt.hpp +++ b/rdbms/wrapper/PostgresStmt.hpp @@ -293,7 +293,7 @@ private: /** * The parameter count of prepared statement. */ - int m_nParams; + int m_nParams = 0; /** * Used as an array of characeter pointers to C-string needed by libpq @@ -320,7 +320,7 @@ private: /** * The number of rows affected by the last execution of this statement. */ - uint64_t m_nbAffectedRows; + uint64_t m_nbAffectedRows = 0; /** * Templated bind of an optional number. diff --git a/rdbms/wrapper/SqliteRset.cpp b/rdbms/wrapper/SqliteRset.cpp index e5caecfb1d..6d530287af 100644 --- a/rdbms/wrapper/SqliteRset.cpp +++ b/rdbms/wrapper/SqliteRset.cpp @@ -48,19 +48,13 @@ public: /** * The index of the column. */ - int colIdx; + int colIdx = 0; /** * The type of the column as return by the sqlite3_column_type() function * before any type conversion has taken place. */ - int colType; - - /** - * Constructor. Set both member-variables to 0. - */ - IdxAndType(): colIdx(0), colType(0) { - } + int colType = 0; }; /** diff --git a/rdbms/wrapper/SqliteStmt.cpp b/rdbms/wrapper/SqliteStmt.cpp index 03309f2dbd..bc51c32c25 100644 --- a/rdbms/wrapper/SqliteStmt.cpp +++ b/rdbms/wrapper/SqliteStmt.cpp @@ -45,9 +45,7 @@ SqliteStmt::SqliteStmt( SqliteConn &conn, const std::string &sql): StmtWrapper(sql), - m_conn(conn), - m_nbAffectedRows(0) { - m_stmt = nullptr; + m_conn(conn) { const int nByte = -1; // Read SQL up to first null terminator const uint maxPrepareRetries = 20; // A worst case scenario of 2 seconds diff --git a/rdbms/wrapper/SqliteStmt.hpp b/rdbms/wrapper/SqliteStmt.hpp index 52fa3a45e1..775217dc32 100644 --- a/rdbms/wrapper/SqliteStmt.hpp +++ b/rdbms/wrapper/SqliteStmt.hpp @@ -190,12 +190,12 @@ private: /** * The prepared statement. */ - sqlite3_stmt *m_stmt; + sqlite3_stmt *m_stmt = nullptr; /** * The number of rows affected by the last execution of this statement. */ - uint64_t m_nbAffectedRows; + uint64_t m_nbAffectedRows = 0; /** * @param autocommitMode The autocommit mode of the statement. diff --git a/scheduler/ArchiveMount.cpp b/scheduler/ArchiveMount.cpp index 04b0488fad..2340993752 100644 --- a/scheduler/ArchiveMount.cpp +++ b/scheduler/ArchiveMount.cpp @@ -23,15 +23,14 @@ //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -cta::ArchiveMount::ArchiveMount(catalogue::Catalogue& catalogue) : m_catalogue(catalogue), m_sessionRunning(false) {} +cta::ArchiveMount::ArchiveMount(catalogue::Catalogue& catalogue) : m_catalogue(catalogue) {} //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ cta::ArchiveMount::ArchiveMount(catalogue::Catalogue& catalogue, std::unique_ptr dbMount) - : m_catalogue(catalogue), - m_sessionRunning(false) { + : m_catalogue(catalogue) { m_dbMount.reset(dynamic_cast(dbMount.release())); if (!m_dbMount) { throw WrongMountType("Could not cast mount to SchedulerDatabase::ArchiveMount"); diff --git a/scheduler/ArchiveMount.hpp b/scheduler/ArchiveMount.hpp index 69fd8e5d37..4fab3e57f7 100644 --- a/scheduler/ArchiveMount.hpp +++ b/scheduler/ArchiveMount.hpp @@ -248,7 +248,7 @@ protected: /** * Internal tracking of the session completion */ - std::atomic m_sessionRunning; + std::atomic m_sessionRunning = 0; private: /** An initialized-once factory for archive reports (indirectly used by ArchiveJobs)*/ diff --git a/scheduler/OStoreDB/MemQueues.hpp b/scheduler/OStoreDB/MemQueues.hpp index 433b391b09..0382c6d826 100644 --- a/scheduler/OStoreDB/MemQueues.hpp +++ b/scheduler/OStoreDB/MemQueues.hpp @@ -132,21 +132,19 @@ class MemQueueRequest { public: MemQueueRequest(typename Request::JobDump& job, Request& archiveRequest) : m_job(job), - m_request(archiveRequest), - m_promise(std::make_shared>()), - m_tid(::syscall(SYS_gettid)) {} + m_request(archiveRequest) {} virtual ~MemQueueRequest() { threading::MutexLocker ml(m_mutex); } private: typename Request::JobDump m_job; Request & m_request; - std::shared_ptr> m_promise; + std::shared_ptr> m_promise = std::make_shared>(); std::shared_ptr> m_returnValue; // Mutex protecting users against premature deletion threading::Mutex m_mutex; // Helper for debugging - pid_t m_tid; + pid_t m_tid = ::syscall(SYS_gettid); }; template diff --git a/scheduler/OStoreDB/OStoreDB.cpp b/scheduler/OStoreDB/OStoreDB.cpp index 5b4d394244..eb80c6250b 100644 --- a/scheduler/OStoreDB/OStoreDB.cpp +++ b/scheduler/OStoreDB/OStoreDB.cpp @@ -62,9 +62,7 @@ using namespace objectstore; // OStoreDB::OStoreDB() //------------------------------------------------------------------------------ OStoreDB::OStoreDB(objectstore::Backend& be, catalogue::Catalogue& catalogue, log::Logger& logger) - : m_taskQueueSize(0), - m_taskPostingSemaphore(5), - m_objectStore(be), + : m_objectStore(be), m_catalogue(catalogue), m_logger(logger) { m_tapeDrivesState = std::make_unique(m_catalogue); @@ -3691,9 +3689,7 @@ OStoreDB::ArchiveMount::getNextJobBatch(uint64_t filesRequested, uint64_t bytesR // OStoreDB::ArchiveJob::ArchiveJob() //------------------------------------------------------------------------------ OStoreDB::ArchiveJob::ArchiveJob(const std::string& jobAddress, OStoreDB& oStoreDB) - : m_jobOwned(false), - m_mountId(0), - m_oStoreDB(oStoreDB), + : m_oStoreDB(oStoreDB), m_archiveRequest(jobAddress, m_oStoreDB.m_objectStore) {} //------------------------------------------------------------------------------ diff --git a/scheduler/OStoreDB/OStoreDB.hpp b/scheduler/OStoreDB/OStoreDB.hpp index f0938af589..857baddc0a 100644 --- a/scheduler/OStoreDB/OStoreDB.hpp +++ b/scheduler/OStoreDB/OStoreDB.hpp @@ -98,10 +98,10 @@ private: }; std::vector m_enqueueingWorkerThreads; - std::atomic m_taskQueueSize; // < This counter ensures destruction happens after the last thread completed. + std::atomic m_taskQueueSize = 0; // < This counter ensures destruction happens after the last thread completed. /// Delay introduced before posting to the task queue when it becomes too long. void delayIfNecessary(log::LogContext& lc); - cta::threading::Semaphore m_taskPostingSemaphore; + cta::threading::Semaphore m_taskPostingSemaphore{5}; public: void waitSubthreadsComplete() override; @@ -263,8 +263,8 @@ public: private: ArchiveJob(const std::string& jobAddress, OStoreDB& oStoreDB); - bool m_jobOwned; - uint64_t m_mountId; + bool m_jobOwned = false; + uint64_t m_mountId = 0; std::string m_tapePool; OStoreDB& m_oStoreDB; objectstore::ArchiveRequest m_archiveRequest; @@ -365,17 +365,15 @@ public: private: // Can be instantiated from a mount (queue to transfer) or a report queue RetrieveJob(const std::string& jobAddress, OStoreDB& oStoreDB, RetrieveMount* rm) - : m_jobOwned(false), - m_mountId(0), - m_oStoreDB(oStoreDB), + : m_oStoreDB(oStoreDB), m_retrieveRequest(jobAddress, m_oStoreDB.m_objectStore), m_retrieveMount(rm) {} void asyncDeleteJob(); void waitAsyncDelete(); private: - bool m_jobOwned; - uint64_t m_mountId; + bool m_jobOwned = false; + uint64_t m_mountId = 0; OStoreDB& m_oStoreDB; objectstore::RetrieveRequest m_retrieveRequest; OStoreDB::RetrieveMount* m_retrieveMount; diff --git a/statistics/StatisticsSaveCmdLineArgs.cpp b/statistics/StatisticsSaveCmdLineArgs.cpp index 20775c36e3..fe5cc35e13 100644 --- a/statistics/StatisticsSaveCmdLineArgs.cpp +++ b/statistics/StatisticsSaveCmdLineArgs.cpp @@ -27,8 +27,7 @@ namespace cta::statistics { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -StatisticsSaveCmdLineArgs::StatisticsSaveCmdLineArgs(const int argc, char *const *const argv): - help(false) { +StatisticsSaveCmdLineArgs::StatisticsSaveCmdLineArgs(const int argc, char *const *const argv) { static struct option longopts[] = { {"catalogueconf", required_argument, nullptr, 'c'}, {"help", no_argument, nullptr, 'h'}, diff --git a/statistics/StatisticsSaveCmdLineArgs.hpp b/statistics/StatisticsSaveCmdLineArgs.hpp index 20ebfc8dff..e4c636b7e6 100644 --- a/statistics/StatisticsSaveCmdLineArgs.hpp +++ b/statistics/StatisticsSaveCmdLineArgs.hpp @@ -29,7 +29,7 @@ struct StatisticsSaveCmdLineArgs { /** * True if the usage message should be printed. */ - bool help; + bool help = false; /** * Path to the file containing the connection details of the catalogue diff --git a/statistics/StatisticsUpdateCmdLineArgs.cpp b/statistics/StatisticsUpdateCmdLineArgs.cpp index d82f3cebb8..e17460edfd 100644 --- a/statistics/StatisticsUpdateCmdLineArgs.cpp +++ b/statistics/StatisticsUpdateCmdLineArgs.cpp @@ -28,8 +28,7 @@ namespace cta::statistics { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -StatisticsUpdateCmdLineArgs::StatisticsUpdateCmdLineArgs(const int argc, char *const *const argv): - help(false) { +StatisticsUpdateCmdLineArgs::StatisticsUpdateCmdLineArgs(const int argc, char *const *const argv) { static struct option longopts[] = { {"help", no_argument, nullptr, 'h'}, {nullptr , 0, nullptr, 0} diff --git a/statistics/StatisticsUpdateCmdLineArgs.hpp b/statistics/StatisticsUpdateCmdLineArgs.hpp index f143805432..09dc94a4a0 100644 --- a/statistics/StatisticsUpdateCmdLineArgs.hpp +++ b/statistics/StatisticsUpdateCmdLineArgs.hpp @@ -29,7 +29,7 @@ struct StatisticsUpdateCmdLineArgs { /** * True if the usage message should be printed. */ - bool help; + bool help = false; /** * Path to the file containing the connection details of the catalogue diff --git a/tapeserver/castor/tape/tapeserver/SCSI/Device.hpp b/tapeserver/castor/tape/tapeserver/SCSI/Device.hpp index 42b1146ee5..921a18f406 100644 --- a/tapeserver/castor/tape/tapeserver/SCSI/Device.hpp +++ b/tapeserver/castor/tape/tapeserver/SCSI/Device.hpp @@ -45,12 +45,9 @@ struct DeviceInfo { class DeviceFile { public: /* We avoid being hit by the macros major() and minor() by using a longer syntax */ - DeviceFile() { - major = 0; - minor = 0; - } - unsigned int major; - unsigned int minor; + DeviceFile() = default; + unsigned int major = 0; + unsigned int minor = 0; bool operator !=(const DeviceFile& b) const { return major != b.major || minor != b.minor; diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataPipeline.hpp b/tapeserver/castor/tape/tapeserver/daemon/DataPipeline.hpp index 35d52f6652..c5280934a9 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataPipeline.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataPipeline.hpp @@ -23,21 +23,21 @@ namespace castor::tape::tapeserver::daemon { -/* A double fixed payload pipeline: at creation time, we know how many blocks - * will go through the FIFO (its size). The provide block method return true as - * long as it still needs more block. False when last block is provided (and +/* A double fixed payload pipeline: at creation time, we know how many blocks + * will go through the FIFO (its size). The provide block method return true as + * long as it still needs more block. False when last block is provided (and * throws an exception after that). - * Sum up - + * Sum up + +------------------------------+ | getFreeBlock| | provideBlock | - <----------+ <----------------+ - | DataPipeline | - | | - +----------> +---------------> - pushDataBlock +------------------------------+ getDataBlock - + <----------+ <----------------+ + | DataPipeline | + | | + +----------> +---------------> + pushDataBlock +------------------------------+ getDataBlock + */ class DataPipeline { public: @@ -46,16 +46,16 @@ public: * @param bn :how many memory block we want in the fifo (its size) */ explicit DataPipeline(uint64_t bn) : - m_blocksNeeded(bn), m_freeBlocksProvided(0), m_dataBlocksPushed(0), m_dataBlocksPopped(0){}; + m_blocksNeeded(bn) {}; ~DataPipeline() noexcept { - cta::threading::MutexLocker ml(m_freeBlockProviderProtection); + cta::threading::MutexLocker ml(m_freeBlockProviderProtection); } - /* + /* * Return a memory block to the object - * @param mb : the memory block to be returned - * @return true true if not all the needed blocks has not yet been provided + * @param mb : the memory block to be returned + * @return true true if not all the needed blocks has not yet been provided */ bool provideBlock(MemBlock *mb) { bool ret; @@ -73,9 +73,9 @@ public: m_freeBlocks.push(mb); return ret; } - - /* - * Get a free block + + /* + * Get a free block * @return a free block */ MemBlock * getFreeBlock() { @@ -93,7 +93,7 @@ public: /** * Push into the object a memory block that has been filled somehow : * tape/disk reading - * @param mb the block we want to push back + * @param mb the block we want to push back */ void pushDataBlock(MemBlock *mb) { { @@ -113,7 +113,7 @@ public: /** * Push into the object a memory block that has been filled somehow : * tape/disk reading - * @param mb the block we want to push back + * @param mb the block we want to push back */ MemBlock * popDataBlock() { MemBlock *ret = m_dataBlocks.pop(); @@ -136,26 +136,26 @@ public: cta::threading::MutexLocker ml(m_countersMutex); return m_dataBlocksPopped >= m_blocksNeeded; } - + private: cta::threading::Mutex m_countersMutex; cta::threading::Mutex m_freeBlockProviderProtection; - + ///the number of memory blocks we want to be provided to the object (its size). const uint64_t m_blocksNeeded; - - ///how many blocks have been currently provided - volatile uint64_t m_freeBlocksProvided; - + + ///how many blocks have been currently provided + volatile uint64_t m_freeBlocksProvided = 0; + ///how many data blocks have been currently pushed - volatile uint64_t m_dataBlocksPushed; + volatile uint64_t m_dataBlocksPushed = 0; ///how many data blocks have been currently taken - volatile uint64_t m_dataBlocksPopped; - + volatile uint64_t m_dataBlocksPopped = 0; + ///thread sage storage of all free blocks cta::threading::BlockingQueue m_freeBlocks; - + ///thread sage storage of all blocks filled with data cta::threading::BlockingQueue m_dataBlocks; }; diff --git a/tapeserver/castor/tape/tapeserver/daemon/DiskStats.hpp b/tapeserver/castor/tape/tapeserver/daemon/DiskStats.hpp index f4e0b52519..eed2b5e3e4 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DiskStats.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DiskStats.hpp @@ -20,72 +20,55 @@ namespace castor::tape::tapeserver::daemon { /** - * Structure holding the timers and stats for the tape session. We use doubles, + * Structure holding the timers and stats for the tape session. We use doubles, * for time and all measurements are in seconds or uint64_t for bytes. */ struct DiskStats { /** Mounting time, in seconds */ - double openingTime; - + double openingTime = 0; + /** Closing time, in seconds */ - double closingTime; - + double closingTime = 0; + /** Cumulated time spent computing checksums */ - double checksumingTime; - + double checksumingTime = 0; + /** Cumulated time spent calling read/write methods on the disk client */ - double readWriteTime; - + double readWriteTime = 0; + /** Cumulated time spent waiting for data blocks. */ - double waitDataTime; - + double waitDataTime = 0; + /** Cumulated time spent waiting for free memory. */ - double waitFreeMemoryTime; - + double waitFreeMemoryTime = 0; + /** Cumulated time spent by the tape thread waiting for a task. */ - double waitInstructionsTime; - + double waitInstructionsTime = 0; + /** Cumulated time spent reporting */ - double waitReportingTime; - + double waitReportingTime = 0; + /** Cumulated time spent reporting */ - double checkingErrorTime; - + double checkingErrorTime = 0; + /** Time spent between the opening of the file and the completion of the transfer */ - double transferTime; - + double transferTime = 0; + /** Total real time spent by the thread/pool. */ - double totalTime; - + double totalTime = 0; + /** Cumulated data volume (actual payload), in bytes. */ - uint64_t dataVolume; - + uint64_t dataVolume = 0; + /** Count of files actually transfered in the session. */ - uint64_t filesCount; - + uint64_t filesCount = 0; + /** Archive file ID of the current file */ - uint64_t fileId; + uint64_t fileId = 0; /** Destination URL for the current file */ std::string dstURL; - /** Constructor: all defaults are zero */ - DiskStats(): openingTime(0.0), - closingTime(0.0), - checksumingTime(0.0), - readWriteTime(0.0), - waitDataTime(0.0), - waitFreeMemoryTime(0.0), - waitInstructionsTime(0.0), - waitReportingTime(0.0), - checkingErrorTime(0.0), - transferTime(0.0), - totalTime(0.0), - dataVolume(0), - filesCount(0), - fileId(0), - dstURL("") {} - /** Accumulate contents of another stats block */ void operator+=(const DiskStats& other) { @@ -104,6 +87,6 @@ namespace castor::tape::tapeserver::daemon { dataVolume += other.dataVolume; } }; - + } // namespace castor::tape::tapeserver::daemon diff --git a/tapeserver/castor/tape/tapeserver/daemon/RecallReportPacker.cpp b/tapeserver/castor/tape/tapeserver/daemon/RecallReportPacker.cpp index c9f476869c..5dc8161cc8 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/RecallReportPacker.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/RecallReportPacker.cpp @@ -35,11 +35,7 @@ namespace castor::tape::tapeserver::daemon { //------------------------------------------------------------------------------ RecallReportPacker::RecallReportPacker(cta::RetrieveMount *retrieveMount, cta::log::LogContext& lc) : ReportPackerInterface(lc), - m_workerThread(*this), m_errorHappened(false), m_retrieveMount(retrieveMount), - m_tapeThreadComplete(false), m_diskThreadComplete(false) -{ - -} + m_workerThread(*this), m_retrieveMount(retrieveMount) {} //------------------------------------------------------------------------------ //Destructor @@ -62,7 +58,7 @@ void RecallReportPacker::reportCompletedJob(std::unique_ptr su //------------------------------------------------------------------------------ //reportFailedJob -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void RecallReportPacker::reportFailedJob(std::unique_ptr failedRetrieveJob, const cta::exception::Exception& ex, cta::log::LogContext& lc) { std::string failureLog = cta::utils::getCurrentLocalTime() + " " + cta::utils::getShortHostname() + diff --git a/tapeserver/castor/tape/tapeserver/daemon/RecallReportPacker.hpp b/tapeserver/castor/tape/tapeserver/daemon/RecallReportPacker.hpp index cfd747223c..f8759748e7 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/RecallReportPacker.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/RecallReportPacker.hpp @@ -51,7 +51,7 @@ public: /** * Create into the RecallReportPacker a report for the failed migration * of migratedFile - * @param migratedFile the file which failed + * @param migratedFile the file which failed * @param ex the reason for the failure * @param lc log context provided by the calling thread. */ @@ -65,7 +65,7 @@ public: /** * Create into the RecallReportPacker a report for an erroneous end of session - * @param msg The error message + * @param msg The error message * @param error_code The error code given by the drive * @param lc log context provided by the calling thread. */ @@ -119,7 +119,7 @@ public: bool errorHappened(); private: - //inner classes use to store content while receiving a report + //inner classes use to store content while receiving a report class Report { public: virtual ~Report() = default; @@ -195,17 +195,17 @@ private: cta::threading::Mutex m_producterProtection; - /** + /** * m_fifo is holding all the report waiting to be processed */ cta::threading::BlockingQueue m_fifo; /** * Is set as true as soon as we process a reportFailedJob - * That we can do a sanity check to make sure we always call - * the right end of the session + * That we can do a sanity check to make sure we always call + * the right end of the session */ - bool m_errorHappened; + bool m_errorHappened = false; /** * The mount object used to send reports @@ -221,12 +221,12 @@ private: /** * Tracking of the tape thread end */ - bool m_tapeThreadComplete; + bool m_tapeThreadComplete = false; /** * Tracking of the disk thread end */ - bool m_diskThreadComplete; + bool m_diskThreadComplete = false; cta::threading::Mutex m_mutex; diff --git a/tapeserver/castor/tape/tapeserver/daemon/ReportPackerInterface.hpp b/tapeserver/castor/tape/tapeserver/daemon/ReportPackerInterface.hpp index 95120fb01a..ac71bc4d99 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/ReportPackerInterface.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/ReportPackerInterface.hpp @@ -43,7 +43,7 @@ enum ReportBatching { class TaskWatchDog; /** - * Utility class that should be inherited privately/protectedly + * Utility class that should be inherited privately/protectedly * the type PlaceHolder is either detail::Recall or detail::Migration */ template @@ -59,11 +59,10 @@ protected: virtual ~ReportPackerInterface() = default; explicit ReportPackerInterface(const cta::log::LogContext& lc) : - m_lc(lc), - m_reportBatching(detail::ReportInBulk), m_watchdog(nullptr) {} + m_lc(lc) {} /** - * Log a set of files independently of the success/failure + * Log a set of files independently of the success/failure * @param c The set of files to log * @param msg The message to be append at the end. */ @@ -82,7 +81,7 @@ protected: } /** - * Log a set of files independently of the success/failure + * Log a set of files independently of the success/failure * @param c The set of files to log * @param msg The message to be append at the end. */ @@ -109,7 +108,7 @@ protected: /** * Define how we should report to the client (by file/in bulk). */ - enum detail::ReportBatching m_reportBatching; + enum detail::ReportBatching m_reportBatching = detail::ReportInBulk; public: /** @@ -122,7 +121,7 @@ public: * Pointer to the watchdog, so we can communicate communication errors * and end of session results to the initial process */ - TaskWatchDog *m_watchdog; + TaskWatchDog *m_watchdog = nullptr; }; diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeSessionReporter.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeSessionReporter.cpp index f517abee13..036a61e299 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeSessionReporter.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeSessionReporter.cpp @@ -29,13 +29,11 @@ namespace castor::tape::tapeserver::daemon { //------------------------------------------------------------------------------ TapeSessionReporter::TapeSessionReporter(cta::tape::daemon::TapedProxy& tapeserverProxy, const cta::tape::daemon::DriveConfigEntry& driveConfig, std::string_view hostname, const cta::log::LogContext& lc) : - m_threadRunning(false), m_tapeserverProxy(tapeserverProxy), m_lc(lc), m_server(hostname), m_unitName(driveConfig.unitName), - m_logicalLibrary(driveConfig.logicalLibrary), - m_sessionPid(getpid()) { + m_logicalLibrary(driveConfig.logicalLibrary) { //change the thread's name in the log m_lc.pushOrReplace(cta::log::Param("thread", "TapeSessionReporter")); } @@ -49,7 +47,7 @@ void TapeSessionReporter::finish() { //------------------------------------------------------------------------------ //startThreads -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void TapeSessionReporter::startThreads() { start(); m_threadRunning = true; @@ -57,7 +55,7 @@ void TapeSessionReporter::startThreads() { //------------------------------------------------------------------------------ //waitThreads -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void TapeSessionReporter::waitThreads() { try { wait(); @@ -73,7 +71,7 @@ void TapeSessionReporter::waitThreads() { //------------------------------------------------------------------------------ //reportState -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void TapeSessionReporter::reportState(cta::tape::session::SessionState state, cta::tape::session::SessionType type) { m_fifo.push(new ReportStateChange(state, type)); @@ -81,7 +79,7 @@ void TapeSessionReporter::reportState(cta::tape::session::SessionState state, //------------------------------------------------------------------------------ //run -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void TapeSessionReporter::run() { while (true) { std::unique_ptr currentReport(m_fifo.pop()); @@ -116,7 +114,7 @@ TapeSessionReporter::ReportStateChange::ReportStateChange(cta::tape::session::Se //------------------------------------------------------------------------------ // ReportStateChange::execute()) -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void TapeSessionReporter::ReportStateChange::execute(TapeSessionReporter & parent) { parent.m_tapeserverProxy.reportState(m_state, m_type, parent.m_volume.vid); } diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeSessionReporter.hpp b/tapeserver/castor/tape/tapeserver/daemon/TapeSessionReporter.hpp index dd647b5111..3fa52aaf45 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeSessionReporter.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeSessionReporter.hpp @@ -39,7 +39,7 @@ public: * @param tapeserverProxy * @param driveConfig The configuration of the tape drive we are using. * @param hostname The host name of the computer - * @param lc + * @param lc */ TapeSessionReporter(cta::tape::daemon::TapedProxy& tapeserverProxy, const cta::tape::daemon::DriveConfigEntry& driveConfig, std::string_view hostname, const cta::log::LogContext& lc); @@ -71,12 +71,12 @@ public: void waitThreads(); private: - bool m_threadRunning; + bool m_threadRunning = false; /* - This internal mechanism could (should ?) be easily changed to a queue + This internal mechanism could (should ?) be easily changed to a queue * of {std/boost}::function coupled with bind. For instance, tapeMountedForWrite - * should look like + * should look like * m_fifo.push(bind(m_tapeserverProxy,&tapeMountedForWrite,args...)) * and execute * while(1) @@ -104,18 +104,18 @@ private: }; /** - * Inherited from Thread, it will do the job : pop a request, execute it + * Inherited from Thread, it will do the job : pop a request, execute it * and delete it */ void run() override; - /** + /** * m_fifo is holding all the report waiting to be processed */ cta::threading::BlockingQueue m_fifo; /** - A bunch of references to proxies to send messages to the + A bunch of references to proxies to send messages to the * outside world when we have to */ cta::tape::daemon::TapedProxy& m_tapeserverProxy; @@ -129,7 +129,7 @@ private: const std::string m_unitName; const std::string m_logicalLibrary; castor::tape::tapeserver::daemon::VolumeInfo m_volume; - const pid_t m_sessionPid; + const pid_t m_sessionPid = getpid(); }; } // namespace castor::tape::tapeserver::daemon diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeSessionStats.hpp b/tapeserver/castor/tape/tapeserver/daemon/TapeSessionStats.hpp index c336ea7393..601c3ad87c 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeSessionStats.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeSessionStats.hpp @@ -20,100 +20,91 @@ namespace castor::tape::tapeserver::daemon { /** - * Structure holding the timers and stats for the tape session. We use doubles, + * Structure holding the timers and stats for the tape session. We use doubles, * for time and all measurements are in seconds or uint64_t for bytes. */ struct TapeSessionStats { /** Mounting time, in seconds */ - double mountTime; - + double mountTime = 0; + /** Cumulated positioning time, in seconds. */ - double positionTime; - + double positionTime = 0; + /** Cumulated time spent computing checksums */ - double checksumingTime; - + double checksumingTime = 0; + /** Cumulated time spent reading and writing data with the drive (for both data and headers). */ - double readWriteTime; - + double readWriteTime = 0; + /** Cumulated time spent flushing */ - double flushTime; - + double flushTime = 0; + /** Unload time, in seconds. */ - double unloadTime; - + double unloadTime = 0; + /** Unmount time, in seconds. */ - double unmountTime; - + double unmountTime = 0; + /** Time spent running encryption control scripts */ - double encryptionControlTime; - + double encryptionControlTime = 0; + /** Cumulated time spent waiting for data blocks. */ - double waitDataTime; - + double waitDataTime = 0; + /** Cumulated time spent waiting for free memory. */ - double waitFreeMemoryTime; - + double waitFreeMemoryTime = 0; + /** Cumulated time spent by the tape thread waiting for a task. */ - double waitInstructionsTime; - + double waitInstructionsTime = 0; + /** Cumulated time spent reporting */ - double waitReportingTime; - - /** Time spent during the session, except mounting, positioning and + double waitReportingTime = 0; + + /** Time spent during the session, except mounting, positioning and * unloading / unmounting. This a derived value */ double transferTime() const { return checksumingTime + readWriteTime + flushTime + waitDataTime + waitFreeMemoryTime + waitInstructionsTime + waitReportingTime; } - + /** Total time of the session, computed in parallel */ - double totalTime; + double totalTime = 0; - /** Time to delivery data to the client equal disk threads totalTime + /** Time to delivery data to the client equal disk threads totalTime * for recall and the tape thread totalTime for migration */ - double deliveryTime; - + double deliveryTime = 0; + /** Cumulated data volume (actual payload), in bytes. */ - uint64_t dataVolume; - + uint64_t dataVolume = 0; + /** Cumulated space used by file headers. */ - uint64_t headerVolume; - + uint64_t headerVolume = 0; + /** Count of files actually transfered in the session. */ - uint64_t filesCount; - + uint64_t filesCount = 0; + /** Count of files coming from repack retrieve request transfered in the session.*/ - uint64_t repackFilesCount; - + uint64_t repackFilesCount = 0; + /** Count of files coming from user retrieve request transfered in the session.*/ - uint64_t userFilesCount; - + uint64_t userFilesCount = 0; + /** Count of files coming from verify-only retrieve requests in the session.*/ - uint64_t verifiedFilesCount; - + uint64_t verifiedFilesCount = 0; + /** Count of bytes coming from repack retrieve request transfered in the session.*/ - uint64_t repackBytesCount; - + uint64_t repackBytesCount = 0; + /** Count of bytes coming from user retrieve request transfered in the session.*/ - uint64_t userBytesCount; - + uint64_t userBytesCount = 0; + /** Count of bytes coming from verify-only retrieve requests in the session.*/ - uint64_t verifiedBytesCount; - + uint64_t verifiedBytesCount = 0; + static const uint64_t headerVolumePerFile = 3*80; static const uint64_t trailerVolumePerFile = 3*80; - - /** Constructor: all defaults are zero */ - TapeSessionStats(): mountTime(0.0), positionTime(0.0), checksumingTime(0.0), - readWriteTime(0.0), flushTime(0.0), unloadTime(0.0), unmountTime(0.0), - encryptionControlTime(0.0), waitDataTime(0.0), waitFreeMemoryTime(0.0), - waitInstructionsTime(0.0), waitReportingTime(0.0), totalTime(0.0), - deliveryTime(0.0), dataVolume(0), headerVolume(0), filesCount(0), repackFilesCount(0), - userFilesCount(0), verifiedFilesCount(0), repackBytesCount(0), userBytesCount(0), - verifiedBytesCount(0) {} - + /** Accumulate contents of another stats block */ void add(const TapeSessionStats& other) { mountTime += other.mountTime; @@ -141,5 +132,5 @@ namespace castor::tape::tapeserver::daemon { verifiedBytesCount += other.verifiedBytesCount; } }; - + } // namespace castor::tape::tapeserver::daemon diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp b/tapeserver/castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp index 1704f0335d..b343438e7f 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp @@ -77,7 +77,7 @@ protected: /** * Integer to notify the tapeserver if the drive has to be put down or not. */ - Session::EndOfSessionAction m_hardwareStatus; + Session::EndOfSessionAction m_hardwareStatus = Session::MARK_DRIVE_AS_UP; /** Session statistics */ TapeSessionStats m_stats; @@ -292,7 +292,7 @@ public: const bool useEncryption, const std::string& externalEncryptionKeyScript, const uint32_t tapeLoadTimeout) : m_drive(drive), m_mediaChanger(mc), m_reporter(tsr), m_vid(volInfo.vid), m_logContext(lc), - m_volInfo(volInfo), m_hardwareStatus(Session::MARK_DRIVE_AS_UP), + m_volInfo(volInfo), m_encryptionControl(useEncryption, externalEncryptionKeyScript), m_tapeLoadTimeout(tapeLoadTimeout) {} }; // class TapeSingleThreadInterface diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp index 2743409fed..9ab1abc7c3 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp @@ -49,8 +49,6 @@ castor::tape::tapeserver::daemon::TapeWriteSingleThread::TapeWriteSingleThread( m_filesBeforeFlush(filesBeforeFlush), m_bytesBeforeFlush(bytesBeforeFlush), m_reportPacker(reportPacker), - m_lastFseq(0), - m_compress(true), m_useLbp(useLbp), m_watchdog(watchdog), m_archiveMount(archiveMount), diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp index 249d48c3c6..315e84604b 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp @@ -168,12 +168,12 @@ private: * It should be const, but it cant * (because there is no mutable function member in c++) */ - uint64_t m_lastFseq; + uint64_t m_lastFseq = 0; /** * Should the compression be enabled ? This is currently hard coded to true */ - const bool m_compress; + const bool m_compress = false; /** * The boolean variable describing to use on not to use Logical diff --git a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp index ee4a907c90..e3f63b4b67 100644 --- a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp +++ b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp @@ -101,9 +101,7 @@ std::string drive::getSerialNumber(const int& fd, System::virtualWrapper& sw) { drive::DriveGeneric::DriveGeneric(SCSI::DeviceInfo di, System::virtualWrapper& sw) : m_SCSIInfo(di), - m_tapeFD(-1), - m_sysWrapper(sw), - m_lbpToUse(lbpToUse::disabled) { + m_sysWrapper(sw) { /* Open the device files */ /* We open the tape device file non-blocking as blocking open on rewind tapes (at least) * will fail after a long timeout when no tape is present (at least with mhvtl) diff --git a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp index f1e9a049e1..edf47f586d 100644 --- a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp +++ b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp @@ -475,9 +475,9 @@ public: protected: SCSI::DeviceInfo m_SCSIInfo; - int m_tapeFD; + int m_tapeFD = -1; castor::tape::System::virtualWrapper & m_sysWrapper; - lbpToUse m_lbpToUse; + lbpToUse m_lbpToUse = lbpToUse::disabled; /** * Set the MTFastEOM option of the ST driver. This function is used only internally in diff --git a/tapeserver/castor/tape/tapeserver/drive/DriveInterface.hpp b/tapeserver/castor/tape/tapeserver/drive/DriveInterface.hpp index 869eefac7a..e450aeb60c 100644 --- a/tapeserver/castor/tape/tapeserver/drive/DriveInterface.hpp +++ b/tapeserver/castor/tape/tapeserver/drive/DriveInterface.hpp @@ -43,22 +43,21 @@ namespace castor::tape::tapeserver::drive { */ class compressionStats { public: - compressionStats() - : fromHost(0), toTape(0), fromTape(0), toHost(0) {} + compressionStats() = default; // migration stats // amount of bytes the host sent - uint64_t fromHost; + uint64_t fromHost = 0; // amount of bytes really wrote on byte - uint64_t toTape; + uint64_t toTape = 0; //-------------------------------------------------------------------------- // recall stats : currently filled by the drive but unused elsewhere // amount of bytes the drive read on tape - uint64_t fromTape; + uint64_t fromTape = 0; // amount of bytes we send to the client - uint64_t toHost; + uint64_t toHost = 0; }; /** diff --git a/tapeserver/castor/tape/tapeserver/drive/FakeDrive.cpp b/tapeserver/castor/tape/tapeserver/drive/FakeDrive.cpp index cf3e17f869..720bb2038d 100644 --- a/tapeserver/castor/tape/tapeserver/drive/FakeDrive.cpp +++ b/tapeserver/castor/tape/tapeserver/drive/FakeDrive.cpp @@ -26,14 +26,14 @@ const char filemark[] = ""; castor::tape::tapeserver::drive::FakeDrive::FakeDrive(uint64_t capacity, FailureMoment failureMoment, bool failToMount) noexcept - : m_currentPosition(0), m_tapeCapacity(capacity), m_beginOfCompressStats(0), - m_failureMoment(failureMoment), m_tapeOverflow(false), + : m_tapeCapacity(capacity), + m_failureMoment(failureMoment), m_failToMount(failToMount), m_lbpToUse(lbpToUse::disabled) { m_tape.reserve(max_fake_drive_record_length); } -castor::tape::tapeserver::drive::FakeDrive::FakeDrive(bool failToMount) noexcept : m_currentPosition(0), m_tapeCapacity(std::numeric_limits::max()), m_beginOfCompressStats(0), - m_failureMoment(OnWrite), m_tapeOverflow(false), m_failToMount(failToMount) { +castor::tape::tapeserver::drive::FakeDrive::FakeDrive(bool failToMount) noexcept : m_tapeCapacity(std::numeric_limits::max()), + m_failureMoment(OnWrite), m_failToMount(failToMount) { m_tape.reserve(max_fake_drive_record_length); } diff --git a/tapeserver/castor/tape/tapeserver/drive/FakeDrive.hpp b/tapeserver/castor/tape/tapeserver/drive/FakeDrive.hpp index 1e0c781f49..d32db7ec76 100644 --- a/tapeserver/castor/tape/tapeserver/drive/FakeDrive.hpp +++ b/tapeserver/castor/tape/tapeserver/drive/FakeDrive.hpp @@ -36,9 +36,9 @@ class FakeDrive : public DriveInterface { uint64_t remainingSpaceAfter; }; std::vector m_tape; - uint32_t m_currentPosition; + uint32_t m_currentPosition = 0; uint64_t m_tapeCapacity; - int m_beginOfCompressStats; + int m_beginOfCompressStats = 0; uint64_t getRemaingSpace(uint32_t currentPosition); public: @@ -46,7 +46,7 @@ class FakeDrive : public DriveInterface { private: const enum FailureMoment m_failureMoment; - bool m_tapeOverflow; + bool m_tapeOverflow = false; bool m_failToMount; lbpToUse m_lbpToUse; diff --git a/tapeserver/castor/tape/tapeserver/file/FileWriter.cpp b/tapeserver/castor/tape/tapeserver/file/FileWriter.cpp index dcb1263643..8502e32b23 100644 --- a/tapeserver/castor/tape/tapeserver/file/FileWriter.cpp +++ b/tapeserver/castor/tape/tapeserver/file/FileWriter.cpp @@ -30,8 +30,7 @@ namespace castor::tape::tapeFile { FileWriter::FileWriter(const std::unique_ptr& ws, const cta::ArchiveJob &fileToMigrate, const size_t blockSize) - : m_currentBlockSize(blockSize), m_session(ws), m_fileToMigrate(fileToMigrate), - m_open(false), m_nonzeroFileWritten(false), m_numberOfBlocks(0) { + : m_currentBlockSize(blockSize), m_session(ws), m_fileToMigrate(fileToMigrate) { // Check the sanity of the parameters. fSeq should be >= 1 if (0 == m_fileToMigrate.archiveFile.archiveFileID || m_fileToMigrate.tapeFile.fSeq < 1) { std::ostringstream err; diff --git a/tapeserver/castor/tape/tapeserver/file/FileWriter.hpp b/tapeserver/castor/tape/tapeserver/file/FileWriter.hpp index ff474288a5..2a4f54e377 100644 --- a/tapeserver/castor/tape/tapeserver/file/FileWriter.hpp +++ b/tapeserver/castor/tape/tapeserver/file/FileWriter.hpp @@ -102,17 +102,17 @@ private: /** * set to true whenever the constructor is called and to false when close() is called */ - bool m_open; + bool m_open = false; /** * set to false initially, set to true after at least one successful nonzero writeBlock operation */ - bool m_nonzeroFileWritten; + bool m_nonzeroFileWritten = false; /** * number of blocks written for the current file */ - int m_numberOfBlocks; + int m_numberOfBlocks = 0; /** * BlockId of the file (tape block id of the first header block). diff --git a/tapeserver/castor/tape/tapeserver/file/OsmFileStructure.cpp b/tapeserver/castor/tape/tapeserver/file/OsmFileStructure.cpp index 725f5a723d..3e83ea6430 100644 --- a/tapeserver/castor/tape/tapeserver/file/OsmFileStructure.cpp +++ b/tapeserver/castor/tape/tapeserver/file/OsmFileStructure.cpp @@ -30,17 +30,13 @@ castor::tape::tapeFile::osm::LABEL::LABEL() { memset(m_tcVersion, 0x20, sizeof(m_tcVersion)); memset(m_tcName, 0x20, sizeof(m_tcName)); memset(m_tcOwner, 0x20, sizeof(m_tcOwner)); - m_ulCreateTime = 0; - m_ulExpireTime = 0; - m_ulRecSize = 0; - m_ulVolId = 0; } void castor::tape::tapeFile::osm::LABEL::decode() { xdr::Record record; xdr::VolLabel volLabel, *pVolLabel; XDR xdr;// xdr handle; - + xdrmem_create(&xdr, rawLabel(), LIMITS::MAXMRECSIZE, XDR_DECODE); if(!record.decode(&xdr)) { throw cta::exception::Exception(std::string("XDR error getting record")); @@ -48,10 +44,10 @@ void castor::tape::tapeFile::osm::LABEL::decode() { if(record.m_RChunk.m_pChunk == nullptr) { throw cta::exception::Exception(std::string("Invalid label format - no record chunk")); } - + pVolLabel = reinterpret_cast(record.m_RChunk.m_pChunk->m_data.m_pcDataVal); xdr_destroy(&xdr); - + if(pVolLabel == nullptr) { throw cta::exception::Exception(std::string("Invalid label format - no label chunk")); } @@ -78,7 +74,7 @@ void castor::tape::tapeFile::osm::LABEL::decode() { m_ulExpireTime = volLabel.m_ulExpireTime; m_ulRecSize = volLabel.m_ulRecSize; m_ulVolId = volLabel.m_ulVolId; - + memcpy(m_tcOwner, rawLabel() + LIMITS::MAXMRECSIZE, LIMITS::CIDLEN); memcpy(m_tcVersion, rawLabel() + LIMITS::MAXMRECSIZE + LIMITS::CIDLEN, LIMITS::LABELVERSIONLEN); } diff --git a/tapeserver/castor/tape/tapeserver/file/OsmFileStructure.hpp b/tapeserver/castor/tape/tapeserver/file/OsmFileStructure.hpp index 7128e044a7..fb43579a4c 100644 --- a/tapeserver/castor/tape/tapeserver/file/OsmFileStructure.hpp +++ b/tapeserver/castor/tape/tapeserver/file/OsmFileStructure.hpp @@ -93,10 +93,10 @@ protected: char m_tcVersion[LIMITS::LABELVERSIONLEN]; char m_tcName[LIMITS::VOLNAMELEN+1]; char m_tcRawLabel[2 * LIMITS::MAXMRECSIZE]; - uint64_t m_ulCreateTime; - uint64_t m_ulExpireTime; - uint64_t m_ulRecSize; - uint64_t m_ulVolId; + uint64_t m_ulCreateTime = 0; + uint64_t m_ulExpireTime = 0; + uint64_t m_ulRecSize = 0; + uint64_t m_ulVolId = 0; }; } // namespace castor::tape::tapeFile::osm diff --git a/tapeserver/castor/tape/tapeserver/file/ReadSession.cpp b/tapeserver/castor/tape/tapeserver/file/ReadSession.cpp index 3b52335b37..970e871936 100644 --- a/tapeserver/castor/tape/tapeserver/file/ReadSession.cpp +++ b/tapeserver/castor/tape/tapeserver/file/ReadSession.cpp @@ -26,9 +26,7 @@ namespace castor::tape::tapeFile { ReadSession::ReadSession(tapeserver::drive::DriveInterface &drive, const tapeserver::daemon::VolumeInfo &volInfo, const bool useLbp) - : m_drive(drive), m_vid(volInfo.vid), m_useLbp(useLbp), m_corrupted(false), - m_locked(false), m_fseq(1), m_currentFilePart(PartOfFile::Header), m_volInfo(volInfo), - m_detectedLbp(false) { + : m_drive(drive), m_vid(volInfo.vid), m_useLbp(useLbp), m_volInfo(volInfo) { if (!m_vid.compare("")) { throw cta::exception::InvalidArgument(); } diff --git a/tapeserver/castor/tape/tapeserver/file/ReadSession.hpp b/tapeserver/castor/tape/tapeserver/file/ReadSession.hpp index 693da2038b..24f745ee6e 100644 --- a/tapeserver/castor/tape/tapeserver/file/ReadSession.hpp +++ b/tapeserver/castor/tape/tapeserver/file/ReadSession.hpp @@ -139,29 +139,29 @@ protected: /** * set to true in case the destructor of ReadFile finds a missing lock on its session */ - bool m_corrupted; + bool m_corrupted = false; /** * Session lock to be sure that a read session is owned by maximum one ReadFile object */ - bool m_locked; + bool m_locked = false; /** * Current fSeq, used only for positioning by fseq */ - uint32_t m_fseq; + uint32_t m_fseq = 1; /** * Part of the file we are reading */ - PartOfFile m_currentFilePart; + PartOfFile m_currentFilePart = PartOfFile::Header; const tapeserver::daemon::VolumeInfo m_volInfo; /** * The boolean variable indicates that the tape has VOL1 with enabled LBP */ - bool m_detectedLbp; + bool m_detectedLbp = false; }; }} // namespace castor::tape::tapeFile diff --git a/tapeserver/castor/tape/tapeserver/file/Structures.hpp b/tapeserver/castor/tape/tapeserver/file/Structures.hpp index b16fa994c3..7950b7a460 100644 --- a/tapeserver/castor/tape/tapeserver/file/Structures.hpp +++ b/tapeserver/castor/tape/tapeserver/file/Structures.hpp @@ -25,7 +25,7 @@ namespace castor::tape::tapeFile { /** - * Helper template to fill with space a structure. + * Helper template to fill with space a structure. * @param s pointer the struct/class. */ template @@ -35,9 +35,9 @@ namespace castor::tape::tapeFile { template /** - * Templated helper function to get std::string from the char array + * Templated helper function to get std::string from the char array * not terminated by '\0'. - * + * * @param t array pointer to the char array. * @return std::string for the char array */ @@ -54,8 +54,8 @@ namespace castor::tape::tapeFile { spaceStruct(this); } protected: - char m_label[4]; // The characters VOL1. - char m_VSN[6]; // The Volume Serial Number. + char m_label[4]; // The characters VOL1. + char m_VSN[6]; // The Volume Serial Number. char m_accessibility[1]; // A space indicates that the volume is authorized. char m_reserved1[13]; // Reserved. char m_implID[13]; // The Implementation Identifier - spaces. @@ -66,7 +66,7 @@ namespace castor::tape::tapeFile { // standard. It contains 2 spaces or '00'. Otherwise, contains // the ASCII representation of the hexadecimal value of the // Logical block protection method, as defined in the SSC-5 (latest drafts) - // In practice we intend to use " " (double space) or "00" + // In practice we intend to use " " (double space) or "00" // for no LBP, "02" for CRC32C where possible (enterprise drives) // and "01" for ECMA-319 Reed-Solomon where not (LTO drives). char m_lblStandard[1]; // The label standard level - ASCII 3 for the CASTOR @@ -84,7 +84,7 @@ namespace castor::tape::tapeFile { inline std::string getVSN() const { return toString(m_VSN); } - + /** * @return the logic block protection method as parsed from the header */ @@ -124,9 +124,9 @@ namespace castor::tape::tapeFile { class VOL1withCrc : public VOL1 { public: - VOL1withCrc(): VOL1() { m_crc = 0; } + VOL1withCrc(): VOL1() {} protected: - uint32_t m_crc; // 32bit crc addition for VOL1 + uint32_t m_crc = 0; // 32bit crc addition for VOL1 }; // The common part of the HDR1, EOF1 and PRELEBEL HDR1 labels @@ -138,7 +138,7 @@ namespace castor::tape::tapeFile { spaceStruct(this); } protected: - char m_label[4]; // The characters HDR1. + char m_label[4]; // The characters HDR1. char m_fileId[17]; // The CASTOR NS file Id in ACSII hex or PRELABEL char m_VSN[6]; // The Volume Serial Number. char m_fSec[4]; // The file section number - '0001'. @@ -152,9 +152,9 @@ namespace castor::tape::tapeFile { char m_sysCode[13]; // The system ID code - 'CASTOR '+CASTORBASEVERSION char m_reserved[7]; // Reserved /** - * Fills up all common fields of the HDR1, EOF1 and PRELABEL HDR1 + * Fills up all common fields of the HDR1, EOF1 and PRELABEL HDR1 * structures with proper values and data provided. - * + * * @param fileId The CASTOR NS file Id in ACSII hex. * @param VSN The tape serial number. * @param fSeq The file sequence number on the tape. @@ -188,7 +188,7 @@ namespace castor::tape::tapeFile { inline std::string getfSeq() const { return toString(m_fSeq); } - + /** * @return The number of block written on tape per file (only valid in trailer, fairly useless) */ @@ -200,9 +200,9 @@ namespace castor::tape::tapeFile { class HDR1 : public HDR1EOF1 { public: /** - * Fills up only a few fields of the HDR1 structure with proper values + * Fills up only a few fields of the HDR1 structure with proper values * and data provided. - * + * * @param fileId The CASTOR NS file Id in ACSII hex. * @param VSN The tape serial number. * @param fSeq The file sequence number on the tape. @@ -218,9 +218,9 @@ namespace castor::tape::tapeFile { class EOF1 : public HDR1EOF1 { public: /** - * Fills up only a few fields of the EOF1 structure with proper values + * Fills up only a few fields of the EOF1 structure with proper values * and data provided. - * + * * @param fileId The CASTOR NS file Id in ACSII hex. * @param VSN The tape serial number. * @param fSeq The file sequence number on the tape. @@ -235,13 +235,13 @@ namespace castor::tape::tapeFile { */ void verify(const bool skipFSecCheck = false) const ; }; - + class HDR1PRELABEL : public HDR1EOF1 { public: /** - * Fills up only a few fields of the HDR1 structure with proper values + * Fills up only a few fields of the HDR1 structure with proper values * and data provided. - * + * * @param VSN The tape serial number. */ void fill(std::string VSN); @@ -261,25 +261,25 @@ namespace castor::tape::tapeFile { spaceStruct(this); } protected: - char m_label[4]; // The characters HDR2. - char m_recordFormat[1]; // The record format is 'F' for the CASTOR AUL. + char m_label[4]; // The characters HDR2. + char m_recordFormat[1]; // The record format is 'F' for the CASTOR AUL. char m_blockLength[5]; // If it is greater than 100000 it set as '00000'. char m_recordLength[5]; // If it is greater than 100000 it set as '00000'. char m_tapeDensity[1]; // The tape density code. Not used or verified. char m_reserved1[18]; // Reserved - char m_recTechnique[2]; // The tape recording technique. 'P ' for xxxGC + char m_recTechnique[2]; // The tape recording technique. 'P ' for xxxGC // drives (only on the real tapes on we do not see // it with MHVTL setup). char m_reserved2[14]; // Reserved char m_aulId[2]; // CASTOR specific for the AUL format - '00'. - char m_reserved3[28]; // Reserved + char m_reserved3[28]; // Reserved /** * Fills up all common fields of the HDR2 and EOF2 structures * with proper values and data provided. - * + * * @param blockLength The CASTOR block size. - * @param driveHasCompression The boolean to set If the drive is - * configured to use compression or not. + * @param driveHasCompression The boolean to set If the drive is + * configured to use compression or not. */ void fillCommon(int blockLength, bool driveHasCompression); @@ -289,7 +289,7 @@ namespace castor::tape::tapeFile { void verifyCommon(const char *const formatCharacter = "F") const ; public: /** - * @return The block length + * @return The block length */ inline std::string getBlockLength() const { return toString(m_blockLength); @@ -301,9 +301,9 @@ namespace castor::tape::tapeFile { /** * Fills up a few specific fields fields of the HDR2 structure * with proper values and data provided. - * + * * @param blockLength The CASTOR block size. - * @param driveHasCompression The boolean to set If the drive is + * @param driveHasCompression The boolean to set If the drive is * configured to use compression or not. * By default it is true. */ @@ -320,10 +320,10 @@ namespace castor::tape::tapeFile { /** * Fills up only a few specific fields of the HDR2 structure * with proper values and data provided. - * + * * @param blockLength The CASTOR block size. - * @param driveHasCompression The boolean to set If the drive is - * configured to use compression or not. + * @param driveHasCompression The boolean to set If the drive is + * configured to use compression or not. * By default it si true. */ void fill(int blockLength, bool compression = true); @@ -343,8 +343,8 @@ namespace castor::tape::tapeFile { spaceStruct(this); } protected: - char m_label[4]; // The characters UHL1. - char m_actualfSeq[10]; // The actual file sequence number. + char m_label[4]; // The characters UHL1. + char m_actualfSeq[10]; // The actual file sequence number. char m_actualBlockSize[10]; // The actual block size. char m_actualRecordLength[10];// The actual record length. char m_site[8]; // The domain name uppercase without level 1. @@ -355,7 +355,7 @@ namespace castor::tape::tapeFile { /** * Fills up all common fields of the UHL1 and UTL1 structure with proper * values and data provided. - * + * * @param fSeq The file sequence number. * @param blockSize The block size. * @param siteName The domain name uppercase without level 1 (.ch) @@ -391,9 +391,9 @@ namespace castor::tape::tapeFile { class UHL1 : public UHL1UTL1 { public: /** - * Fills up only specific fields of the UHL1 structure with proper values + * Fills up only specific fields of the UHL1 structure with proper values * and data provided. - * + * * @param fSeq The file sequence number. * @param blockSize The block size. * @param siteName The domain name uppercase without level 1 (.ch) @@ -414,9 +414,9 @@ namespace castor::tape::tapeFile { class UTL1 : public UHL1UTL1 { public: /** - * Fills up only specific fields of the UTL1 structure with proper values + * Fills up only specific fields of the UTL1 structure with proper values * and data provided. - * + * * @param fSeq The file sequence number. * @param blockSize The block size. * @param siteName The domain name uppercase without level 1 (.ch) @@ -462,11 +462,11 @@ namespace castor::tape::tapeFile { memcpy(t, buf, n); } - + template /** * Templated helper function to compare a string with space padded string. - * + * * @return Returns an integer equal to zero if strings match */ int cmpString(const char(& t)[n], const std::string & s) { diff --git a/tapeserver/castor/tape/tapeserver/file/WriteSession.cpp b/tapeserver/castor/tape/tapeserver/file/WriteSession.cpp index 2081e8a4a2..bc11609b07 100644 --- a/tapeserver/castor/tape/tapeserver/file/WriteSession.cpp +++ b/tapeserver/castor/tape/tapeserver/file/WriteSession.cpp @@ -30,8 +30,7 @@ WriteSession::WriteSession(tapeserver::drive::DriveInterface &drive, const uint32_t last_fSeq, const bool compression, const bool useLbp) : m_drive(drive), m_vid(volInfo.vid), m_compressionEnabled(compression), - m_useLbp(useLbp), m_corrupted(false), m_locked(false), - m_volInfo(volInfo), m_detectedLbp(false) { + m_useLbp(useLbp), m_volInfo(volInfo) { if (!m_vid.compare("")) { throw cta::exception::InvalidArgument(); } diff --git a/tapeserver/castor/tape/tapeserver/file/WriteSession.hpp b/tapeserver/castor/tape/tapeserver/file/WriteSession.hpp index d21cc8c921..27fafe4494 100644 --- a/tapeserver/castor/tape/tapeserver/file/WriteSession.hpp +++ b/tapeserver/castor/tape/tapeserver/file/WriteSession.hpp @@ -179,19 +179,19 @@ private: /** * set to true in case the write operations do (or try to do) something illegal */ - bool m_corrupted; + bool m_corrupted = false; /** * Session lock to be sure that a read session is owned by maximum one WriteFile object */ - bool m_locked; + bool m_locked = false; const tapeserver::daemon::VolumeInfo m_volInfo; /** * The boolean variable indicates that the tape has VOL1 with enabled LBP */ - bool m_detectedLbp; + bool m_detectedLbp = false; const uint16_t MAX_UNIX_HOSTNAME_LENGTH = 256; // 255 + 1 terminating character }; diff --git a/tapeserver/castor/tape/tapeserver/system/FileWrappers.cpp b/tapeserver/castor/tape/tapeserver/system/FileWrappers.cpp index e39c5ca21c..53312e3e07 100644 --- a/tapeserver/castor/tape/tapeserver/system/FileWrappers.cpp +++ b/tapeserver/castor/tape/tapeserver/system/FileWrappers.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include "FileWrappers.hpp" @@ -95,14 +95,7 @@ System::stDeviceFile::stDeviceFile() m_mtStat.mt_dsreg = (((256 * 0x400) & MT_ST_BLKSIZE_MASK) << MT_ST_BLKSIZE_SHIFT) | ((1 & MT_ST_DENSITY_MASK) << MT_ST_DENSITY_SHIFT); m_mtStat.mt_gstat = GMT_EOT(~0) | GMT_BOT(~0); - - blockID = 0xFFFFFFFF; // Logical Object ID - position on tape - - clearCompressionStats = false; - m_LBPInfoMethod = 0xFA; - m_LBPInfoLength = 0xBC; - m_LBPInfo_R = 0xCD; - m_LBPInfo_W = 0xAC; + } int System::stDeviceFile::ioctl(unsigned long int request, struct mtop * mt_cmd) @@ -146,7 +139,7 @@ int System::stDeviceFile::ioctl(unsigned long int request, sg_io_hdr_t * sgio_h) case SCSI::Commands::LOCATE_10: return ioctlLocate10(sgio_h); case SCSI::Commands::LOG_SENSE: - return ioctlLogSense(sgio_h); + return ioctlLogSense(sgio_h); case SCSI::Commands::MODE_SENSE_6: return ioctlModSense6(sgio_h); case SCSI::Commands::MODE_SELECT_6: @@ -197,7 +190,7 @@ int System::stDeviceFile::ioctlReadPosition(sg_io_hdr_t* sgio_h) { } else { // we did seek on tape so we have real values /* we need this field to make the replay valid*/ positionData.PERR = 0; - /* fill with internal values + /* fill with internal values * lastBlockLocation=firstBlockLocation as soon as Buffer is empty. */ SCSI::Structures::setU32(positionData.firstBlockLocation, blockID); @@ -492,21 +485,21 @@ int System::stIBM3592DeviceFile::logSenseVolumeStatisticsPage(sg_io_hdr_t * sgio int System::stOracleT10000Device::logSenseVendorUniqueDriveStatisticsPage(sg_io_hdr_t * sgio_h) { unsigned char output[] = { - 0x3d, 0x00, 0x0c, 0x08, 0x01, 0x00, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x74, 0x04, // 0x00 - 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x74, 0x04, // 0x10 + 0x3d, 0x00, 0x0c, 0x08, 0x01, 0x00, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x74, 0x04, // 0x00 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x74, 0x04, // 0x10 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x74, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x05, 0x74, 0x04, // 0x20 0x00, 0x01, 0x01, 0x02, 0x01, 0x06, 0x74, 0x04, 0x01, 0x01, 0x02, 0x02, 0x01, 0x07, 0x74, 0x04, // 0x30 0x00, 0x00, 0x02, 0x13, 0x01, 0x08, 0x74, 0x04, 0x00, 0x02, 0x1a, 0x0f, 0x01, 0x09, 0x74, 0x04, // 0x40 - 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0b, 0x74, 0x04, // 0x50 - 0x00, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0d, 0x74, 0x04, // 0x60 - 0x00, 0x00, 0x00, 0x00, 0x01, 0x0e, 0x74, 0x04, 0x00, 0x00, 0x01, 0x9a, 0x01, 0x10, 0x74, 0x04, // 0x70 - 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x12, 0x74, 0x04, // 0x80 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0b, 0x74, 0x04, // 0x50 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0d, 0x74, 0x04, // 0x60 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x0e, 0x74, 0x04, 0x00, 0x00, 0x01, 0x9a, 0x01, 0x10, 0x74, 0x04, // 0x70 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x12, 0x74, 0x04, // 0x80 0x00, 0x00, 0xff, 0xff, 0x01, 0x14, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x15, 0x74, 0x04, // 0x90 - 0x00, 0x00, 0x00, 0x00, 0x01, 0x16, 0x74, 0x04, 0x00, 0x00, 0x00, 0x65, 0x01, 0x17, 0x74, 0x04, // 0xa0 - 0x00, 0x00, 0x00, 0x01, 0x01, 0x18, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x74, 0x04, // 0xb0 - 0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x22, 0x74, 0x04, // 0xc0 - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x74, 0x04, // 0xd0 - 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x74, 0x04, // 0xe0 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x16, 0x74, 0x04, 0x00, 0x00, 0x00, 0x65, 0x01, 0x17, 0x74, 0x04, // 0xa0 + 0x00, 0x00, 0x00, 0x01, 0x01, 0x18, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x74, 0x04, // 0xb0 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x22, 0x74, 0x04, // 0xc0 + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x74, 0x04, // 0xd0 + 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x74, 0x04, // 0xe0 0x01, 0x00, 0x00, 0x01, 0x02, 0x04, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x74, 0x08, // 0xf0 0x00, 0x00, 0x00, 0x00, 0x0f, 0xa8, 0x03, 0x70, 0x03, 0x01, 0x74, 0x08, 0x00, 0x00, 0x00, 0x00, // 0x100 0x0f, 0xb0, 0x54, 0x58, 0x03, 0x02, 0x74, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x110 @@ -805,8 +798,8 @@ int System::stIBM3592DeviceFile::logSensePerformanceCharacteristicsPage(sg_io_hd int System::stDeviceFile::logSenseSequentialAccessDevicePage(sg_io_hdr_t * sgio_h) { /** - * This is a real reply from the enterprise T10000C STK drive. - * We only fill the testing values in the corresponding fields for the + * This is a real reply from the enterprise T10000C STK drive. + * We only fill the testing values in the corresponding fields for the * compression statistics. The replay1 is the replay with not empty * data and the replay2 is the replay with zero statistics. */ @@ -814,15 +807,15 @@ int System::stDeviceFile::logSenseSequentialAccessDevicePage(sg_io_hdr_t * sgio_ 0x0c, 0x00, 0x00, 0x40, 0x00, 0x00, 0x74, 0x08, 0xab, 0xcd, 0xef, 0x11, 0x22, 0x33, 0x44, 0x55, // 0x00 0x00, 0x01, 0x74, 0x08, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x00, 0x02, 0x74, 0x08, // 0x10 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x11, 0x00, 0x03, 0x74, 0x08, 0x22, 0x33, 0x44, 0x55, // 0x20 - 0x66, 0x77, 0x88, 0x99, 0x01, 0x00, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x74, 0x04, // 0x30 - 0x00, 0x00, 0x00, 0x00 // 0x40 + 0x66, 0x77, 0x88, 0x99, 0x01, 0x00, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x74, 0x04, // 0x30 + 0x00, 0x00, 0x00, 0x00 // 0x40 }; unsigned char replay2[] = { 0x0c, 0x00, 0x00, 0x40, 0x00, 0x00, 0x74, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 0x00, 0x01, 0x74, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x74, 0x08, // 0x10 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x74, 0x08, 0x00, 0x00, 0x00, 0x00, // 0x20 - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x74, 0x04, // 0x30 - 0x00, 0x00, 0x00, 0x00 // 0x40 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x74, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x74, 0x04, // 0x30 + 0x00, 0x00, 0x00, 0x00 // 0x40 }; if (sizeof (replay1) > sgio_h->dxfer_len) { @@ -839,8 +832,8 @@ int System::stDeviceFile::logSenseSequentialAccessDevicePage(sg_io_hdr_t * sgio_ int System::stDeviceFile::logSenseDataCompression32h(sg_io_hdr_t * sgio_h) { /** - * This is a real reply from the IBM ULTRIUM-TD5 LTO5 drive. - * We only fill the testing values in the corresponding fields for the + * This is a real reply from the IBM ULTRIUM-TD5 LTO5 drive. + * We only fill the testing values in the corresponding fields for the * compression statistics. The replay1 is the replay with not empty * data and the replay2 is the replay with zero statistics. */ @@ -873,8 +866,8 @@ int System::stDeviceFile::logSenseDataCompression32h(sg_io_hdr_t * sgio_h) { int System::stDeviceFile::logSenseBlockBytesTransferred(sg_io_hdr_t * sgio_h) { /** - * This is a real reply from the enterprise IBM 03592E06 drive. - * We only fill the testing values in the corresponding fields for the + * This is a real reply from the enterprise IBM 03592E06 drive. + * We only fill the testing values in the corresponding fields for the * compression statistics. The replay1 is the replay with not empty * data and the replay2 is the replay with zero statistics. */ @@ -928,12 +921,12 @@ int System::stDeviceFile::logSenseTapeAlerts(sg_io_hdr_t* sgio_h) { data += 4; remaining -= 4; /* This array was extracted from p/x in gdb of the tape alert log page from * mhvtl, then processed through: - * cat mhvtlAlerts.txt | tr -d "\n" | perl -p -e 's/\},/}\n/g' | grep parameterCode | + * cat mhvtlAlerts.txt | tr -d "\n" | perl -p -e 's/\},/}\n/g' | grep parameterCode | * perl -e 'while (<>) { if ( /\{\s*(0x[[:xdigit:]]+),\s*(0x[[:xdigit:]]+)\}/ ) { print (hex($1) * 256 + hex($2)); print ", " } }'*/ /* We also add an out-of-range 65 */ - uint16_t parameterCodes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + uint16_t parameterCodes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65 }; size_t i = 0; while (remaining > 5 && i < 65) { @@ -963,7 +956,7 @@ int System::stDeviceFile::ioctlModSense6(sg_io_hdr_t * sgio_h) { } SCSI::Structures::modeSense6CDB_t & cdb = *(SCSI::Structures::modeSense6CDB_t *) sgio_h->cmdp; - + switch (cdb.pageCode) { case SCSI::modeSensePages::deviceConfiguration: return modeSenseDeviceConfiguration(sgio_h); @@ -991,7 +984,7 @@ int System::stDeviceFile::modeSenseDeviceConfiguration(sg_io_hdr_t * sgio_h) { /* fill the replay with random data */ srandom(SCSI::Commands::MODE_SENSE_6); memset(sgio_h->dxferp, random(), sizeof (devConfig)); - + /* sets fileds to be used*/ devConfig.modePage.pageCode = SCSI::modeSensePages::deviceConfiguration; return 0; @@ -1003,13 +996,13 @@ int System::stDeviceFile::modeSenseControlDataProtection(sg_io_hdr_t * sgio_h) { if (SCSI::modeSensePages::controlDataProtection != cdb.pageCode) { errno = EINVAL; return -1; - } - + } + if (cdb.subPageCode != SCSI::modePageControlDataProtection::subpageCode) { errno = EINVAL; return -1; - } - + } + SCSI::Structures::modeSenseControlDataProtection_t & controlDataProtection = *(SCSI::Structures::modeSenseControlDataProtection_t *) sgio_h->dxferp; @@ -1020,7 +1013,7 @@ int System::stDeviceFile::modeSenseControlDataProtection(sg_io_hdr_t * sgio_h) { /* fill the replay with random data */ srandom(SCSI::Commands::MODE_SENSE_6); memset(sgio_h->dxferp, random(), sizeof (controlDataProtection)); - + /* fils only used fields */ controlDataProtection.modePage.LBPMethod = m_LBPInfoMethod; controlDataProtection.modePage.LBPInformationLength = m_LBPInfoLength; @@ -1039,13 +1032,13 @@ int System::stDeviceFile::ioctlModSelect6(sg_io_hdr_t * sgio_h) { return -1; } unsigned char * data = (unsigned char *) sgio_h->dxferp; - + SCSI::Structures::modeParameterHeader6_t & header = - *(SCSI::Structures::modeParameterHeader6_t *) sgio_h->dxferp; + *(SCSI::Structures::modeParameterHeader6_t *) sgio_h->dxferp; - SCSI::Structures::modeParameterBlockDecriptor_t & blockDescriptor = + SCSI::Structures::modeParameterBlockDecriptor_t & blockDescriptor = *(SCSI::Structures::modeParameterBlockDecriptor_t *) (data+sizeof(header)); - + unsigned char * modeSelectBlock = data+sizeof(header)+sizeof(blockDescriptor); switch (modeSelectBlock[0]&0x3F) { // only 6bits are the page code @@ -1064,12 +1057,12 @@ int System::stDeviceFile::modeSelectDeviceConfiguration(sg_io_hdr_t * sgio_h) { SCSI::Structures::modeSenseDeviceConfiguration_t & devConfig = *(SCSI::Structures::modeSenseDeviceConfiguration_t *) sgio_h->dxferp; - + if (devConfig.modePage.pageCode != SCSI::modeSensePages::deviceConfiguration) { errno = 5; return -1; } - + if (sizeof (devConfig) > sgio_h->dxfer_len) { errno = 6; return -1; @@ -1095,12 +1088,12 @@ int System::stDeviceFile::modeSelectControlDataProtection(sg_io_hdr_t * sgio_h) SCSI::Structures::modeSenseControlDataProtection_t & controlData = *(SCSI::Structures::modeSenseControlDataProtection_t *) sgio_h->dxferp; - + if (controlData.modePage.pageCode != SCSI::modeSensePages::controlDataProtection) { errno = EINVAL; return -1; } - + if (sizeof (controlData) > sgio_h->dxfer_len) { errno = EINVAL; return -1; @@ -1111,7 +1104,7 @@ int System::stDeviceFile::modeSelectControlDataProtection(sg_io_hdr_t * sgio_h) errno = EINVAL; return -1; } - + m_LBPInfoMethod = controlData.modePage.LBPMethod; m_LBPInfoLength = controlData.modePage.LBPInformationLength; m_LBPInfo_R = controlData.modePage.LBP_R; diff --git a/tapeserver/castor/tape/tapeserver/system/FileWrappers.hpp b/tapeserver/castor/tape/tapeserver/system/FileWrappers.hpp index b09599d133..ba1ba5b20a 100644 --- a/tapeserver/castor/tape/tapeserver/system/FileWrappers.hpp +++ b/tapeserver/castor/tape/tapeserver/system/FileWrappers.hpp @@ -40,21 +40,21 @@ namespace castor::tape::System { /** Reset the read/write pointers at open. This ensures coherent behavior on multiple access */ virtual void reset() = 0; }; - + /** * Class representing real files */ class regularFile: public vfsFile { public: - regularFile(): m_read_pointer(0) {}; - explicit regularFile(const std::string& c) : m_content(c), m_read_pointer(0) {}; + regularFile() {}; + explicit regularFile(const std::string& c) : m_content(c) {}; virtual void reset() { m_read_pointer = 0; }; void operator = (const std::string & s) { m_content = s; m_read_pointer = 0; } virtual ssize_t read(void* buf, size_t nbytes); virtual ssize_t write(const void *buf, size_t nbytes); private: std::string m_content; - int m_read_pointer; + int m_read_pointer = 0; }; /** * Class representing a tape device @@ -69,18 +69,18 @@ namespace castor::tape::System { protected: struct mtget m_mtStat; struct mtop m_mtCmd; - uint32_t blockID; - bool clearCompressionStats; - unsigned char m_LBPInfoMethod; - unsigned char m_LBPInfoLength; - unsigned char m_LBPInfo_R; - unsigned char m_LBPInfo_W; + uint32_t blockID = 0xFFFFFFFF; // Logical Object ID - position on tape + bool clearCompressionStats = false; + unsigned char m_LBPInfoMethod = 0xFA; + unsigned char m_LBPInfoLength = 0xBC; + unsigned char m_LBPInfo_R = 0xCD; + unsigned char m_LBPInfo_W = 0xAC; /** * This function handles READ_POSITION CDB and prepares the reply. - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ virtual int ioctlReadPosition(sg_io_hdr_t * sgio_h); @@ -96,67 +96,67 @@ namespace castor::tape::System { virtual int ioctlRequestSense(sg_io_hdr_t * sgio_h); /** - * This function handles LOG_SELECT CDB and only checks the CDB for the + * This function handles LOG_SELECT CDB and only checks the CDB for the * correct values and sets internal trigger for 0 compression as true. - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ virtual int ioctlLogSelect(sg_io_hdr_t * sgio_h); - + /** - * This function handles LOCATE_10 CDB and only checks the CDB for the + * This function handles LOCATE_10 CDB and only checks the CDB for the * correct values and sets internal blockID variable (logical seek). - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ virtual int ioctlLocate10(sg_io_hdr_t * sgio_h); - + /** * This function handles LOG_SENSE CDB and prepares the replay with * compression data. - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ virtual int ioctlLogSense(sg_io_hdr_t * sgio_h); - + /** * This function handles MODE_SENSE_6 CDB and prepares the replay with * random data. - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ virtual int ioctlModSense6(sg_io_hdr_t * sgio_h); - + /** * This function handles MODE_SELECT_6 CDB and only checks the CDB for the * correct values. - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ virtual int ioctlModSelect6(sg_io_hdr_t * sgio_h); - + /** * This function handles INQUIRY CDB and prepares the standard inquiry * replay or the unit serial number vital product data replay. - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ virtual int ioctlInquiry(sg_io_hdr_t * sgio_h) = 0; @@ -186,37 +186,37 @@ namespace castor::tape::System { virtual int logSenseNonMediumErrorsPage(sg_io_hdr_t * sgio_h) = 0; /** - * This function prepares the replay with compression statistics for - * LOG SENSE CDB with log page Sequential Access Device Page. We use this + * This function prepares the replay with compression statistics for + * LOG SENSE CDB with log page Sequential Access Device Page. We use this * log page for T10000 drives. - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ virtual int logSenseSequentialAccessDevicePage(sg_io_hdr_t * sgio_h); - + /** - * This function prepares the replay with compression statistics for - * LOG SENSE CDB with log page Data Compression (32h). We use this + * This function prepares the replay with compression statistics for + * LOG SENSE CDB with log page Data Compression (32h). We use this * log page for LTO drives. - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ virtual int logSenseDataCompression32h(sg_io_hdr_t * sgio_h); - + /** - * This function prepares the replay with compression statistics for - * LOG SENSE CDB with log page Block Bytes Transferred. We use this + * This function prepares the replay with compression statistics for + * LOG SENSE CDB with log page Block Bytes Transferred. We use this * log page for IBM drives. - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ virtual int logSenseBlockBytesTransferred(sg_io_hdr_t * sgio_h); @@ -225,24 +225,24 @@ namespace castor::tape::System { * This function replies with a pre-cooked error record. As with the real devices, * many parameter codes get reported with a flag set to 0, and a few will * show up with the flag set. - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ int logSenseTapeAlerts(sg_io_hdr_t * sgio_h); - + /** * This function only checks the corectness of the parameters in sg_io_hdr_t * sturcture and returns random data. - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ int modeSenseDeviceConfiguration(sg_io_hdr_t * sgio_h); - + /** * This function checks the corectness of the parameters in sg_io_hdr_t and * returns filled filds: @@ -251,28 +251,28 @@ namespace castor::tape::System { * controlDataProtection.modePage.LBP_R * controlDataProtection.modePage.LBP_W * All other filds in SCSI replay are random. - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ int modeSenseControlDataProtection(sg_io_hdr_t * sgio_h); /** * This function only checks the corectness of the parameters in sg_io_hdr_t - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ int modeSelectDeviceConfiguration(sg_io_hdr_t * sgio_h); /** * This function only checks the corectness of the parameters in sg_io_hdr_t - * - * @param sgio_h The pointer to the sg_io_hdr_t structure with + * + * @param sgio_h The pointer to the sg_io_hdr_t structure with * ioctl call data - * @return Returns 0 in success and + * @return Returns 0 in success and * -1 with appropriate errno if an error occurred. */ int modeSelectControlDataProtection(sg_io_hdr_t * sgio_h); diff --git a/tapeserver/castor/tape/tapeserver/system/Wrapper.hpp b/tapeserver/castor/tape/tapeserver/system/Wrapper.hpp index 22483fa156..0307983dc2 100644 --- a/tapeserver/castor/tape/tapeserver/system/Wrapper.hpp +++ b/tapeserver/castor/tape/tapeserver/system/Wrapper.hpp @@ -34,7 +34,7 @@ namespace castor::tape { -/** +/** * Forward declaration for pointer type in virutalWrapper. */ namespace tapeserver::drive { @@ -47,7 +47,7 @@ namespace System { * Interface class definition, allowing common ancestor between * realWrapper, mockWrapper and fakeWrapper */ - + class virtualWrapper { public: virtual DIR* opendir(const char *name) = 0; @@ -72,7 +72,7 @@ namespace System { getDriveByPath(const std::string & path) = 0; }; - + /** * Wrapper class the all system calls used, allowing writing of test harnesses * for unit testing. For simplicity, the members are virtual functions, and @@ -102,20 +102,19 @@ namespace System { virtual ssize_t write(int fd, const void *buf, size_t nbytes) { return ::write(fd, buf, nbytes); } virtual int close(int fd) { return ::close(fd); } virtual int stat(const char * path, struct stat *buf) { return ::stat(path, buf); } - virtual castor::tape::tapeserver::drive::DriveInterface * + virtual castor::tape::tapeserver::drive::DriveInterface * getDriveByPath(const std::string &) { return nullptr; } }; - + /** * Fake class for system wrapper. Allows recording of pre-cooked filesystem elements, * once for each call separately. - * Each test can then delegate (from mock) and configure + * Each test can then delegate (from mock) and configure */ class fakeWrapper : public virtualWrapper { public: - fakeWrapper() : m_nextFD(0) { - }; + fakeWrapper() {}; virtual DIR* opendir(const char *name); virtual struct dirent * readdir(DIR* dirp); virtual int closedir(DIR* dirp); @@ -129,7 +128,7 @@ namespace System { virtual ssize_t write(int fd, const void *buf, size_t nbytes); virtual int close(int fd); virtual int stat(const char * path, struct stat *buf); - virtual castor::tape::tapeserver::drive::DriveInterface * + virtual castor::tape::tapeserver::drive::DriveInterface * getDriveByPath(const std::string & path); std::map > m_directories; std::map m_links; @@ -154,7 +153,7 @@ namespace System { std::string dent_name; }; std::map m_openFiles; - int m_nextFD; + int m_nextFD = 0; }; /** diff --git a/tapeserver/daemon/TapeDaemon.hpp b/tapeserver/daemon/TapeDaemon.hpp index fc5e1f5038..2bdb107928 100644 --- a/tapeserver/daemon/TapeDaemon.hpp +++ b/tapeserver/daemon/TapeDaemon.hpp @@ -40,16 +40,16 @@ public: const cta::daemon::CommandLineParams & commandLine, cta::log::Logger &log, const common::TapedConfiguration &globalConfig); - + ~TapeDaemon() final; /** The main entry function of the daemon. * @return The return code of the process. */ int mainImpl(); - + private: bool isMaintenanceProcessDisabled() const; - + protected: /** Enumeration of the possible tape-daemon states. */ @@ -81,16 +81,15 @@ protected: struct DriveSocketPair { /** Bi-directional socket used by the TapeDaemon parent process to send * commands to the process forker and receive replies in return. */ - int tapeDaemon; + int tapeDaemon = -1; /** Bi-directional socket used by the ProcessForker to receive commands * from the TapeDaemon parent process and send back replies. */ - int driveProcess; + int driveProcess = -1; /** Constructor. * Sets members to -1 which represents an invalid file descriptor. */ - DriveSocketPair(): tapeDaemon(-1), driveProcess(-1) { - } + DriveSocketPair() {} /** Close utility. Closes both sockets */ void closeBoth(); /** Close utility. Closes drive's socket */ @@ -144,7 +143,7 @@ protected: * Creates the handler to handle messages from forked sessions. */ void createAndRegisterTapeMessageHandler(); - + /** * The main event loop of the daemon. */ @@ -216,7 +215,7 @@ protected: * @param waitpidStat The status information given by a call to waitpid(). */ void logChildProcessTerminated(const pid_t pid, const int waitpidStat) noexcept; - + /** The tape server's configuration */ const common::TapedConfiguration& m_globalConfiguration; diff --git a/tapeserver/readtp/ReadtpCmdLineArgs.cpp b/tapeserver/readtp/ReadtpCmdLineArgs.cpp index f58c7a30a0..3a60dd1f87 100644 --- a/tapeserver/readtp/ReadtpCmdLineArgs.cpp +++ b/tapeserver/readtp/ReadtpCmdLineArgs.cpp @@ -31,8 +31,7 @@ namespace cta::tapeserver::readtp { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -ReadtpCmdLineArgs::ReadtpCmdLineArgs(const int argc, char *const *const argv) : - help(false), m_vid(""), m_destinationFileListURL("") { +ReadtpCmdLineArgs::ReadtpCmdLineArgs(const int argc, char *const *const argv) { if (argc < 3) { help = true; return; @@ -44,9 +43,9 @@ ReadtpCmdLineArgs::ReadtpCmdLineArgs(const int argc, char *const *const argv) : } m_vid = std::string(argv[1]); utils::toUpper(m_vid); - + m_fSeqRangeList = TapeFileSequenceParser::parse(argv[2]); - + static struct option longopts[] = { {"destination_files", required_argument, nullptr, 'f'}, {"drive", required_argument, nullptr, 'u'}, @@ -98,7 +97,7 @@ ReadtpCmdLineArgs::ReadtpCmdLineArgs(const int argc, char *const *const argv) : if (m_destinationFileListURL.empty()) { m_destinationFileListURL = "/dev/null"; // Equivalent to an empty file - } + } } @@ -121,7 +120,7 @@ void ReadtpCmdLineArgs::printUsage(std::ostream &os) { " -f, --destination_files URL to file containing a list of destination files." << std::endl << " If not set, all data read is written to file:///dev/null" << std::endl << " If there are less destination files than read files, the remaining" << std::endl << - " files read will be written to file:///dev/null." << std::endl; + " files read will be written to file:///dev/null." << std::endl; } } // namespace cta::tapeserver::readtp diff --git a/tapeserver/readtp/ReadtpCmdLineArgs.hpp b/tapeserver/readtp/ReadtpCmdLineArgs.hpp index 9acf55481b..e711f770fe 100644 --- a/tapeserver/readtp/ReadtpCmdLineArgs.hpp +++ b/tapeserver/readtp/ReadtpCmdLineArgs.hpp @@ -32,8 +32,8 @@ struct ReadtpCmdLineArgs { /** * True if the usage message should be printed. */ - bool help; - + bool help = false; + /** * The tape VID to read. */ @@ -48,10 +48,10 @@ struct ReadtpCmdLineArgs { * Sequence of file fSeqs to read. */ TapeFseqRangeList m_fSeqRangeList; - + /** * The destination file list url. - */ + */ std::string m_destinationFileListURL; /** diff --git a/tapeserver/tapelabel/TapeLabelCmdLineArgs.cpp b/tapeserver/tapelabel/TapeLabelCmdLineArgs.cpp index 7043598cd3..9414cb1d6e 100644 --- a/tapeserver/tapelabel/TapeLabelCmdLineArgs.cpp +++ b/tapeserver/tapelabel/TapeLabelCmdLineArgs.cpp @@ -30,8 +30,7 @@ namespace cta::tapeserver::tapelabel { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -TapeLabelCmdLineArgs::TapeLabelCmdLineArgs(const int argc, char *const *const argv): - help(false), m_debug(false), m_force(false) { +TapeLabelCmdLineArgs::TapeLabelCmdLineArgs(const int argc, char *const *const argv) { static struct option longopts[] = { {"vid", required_argument, nullptr, 'v'}, @@ -43,7 +42,7 @@ TapeLabelCmdLineArgs::TapeLabelCmdLineArgs(const int argc, char *const *const ar {"help", no_argument, nullptr, 'h'}, {nullptr, 0, nullptr, 0} }; - + // Prevent getopt() from printing an error message if it does not recognize // an option character opterr = 0; @@ -162,7 +161,7 @@ void TapeLabelCmdLineArgs::printUsage(std::ostream &os) { " -u, --drive The unit name of the drive used (if absent, the first drive configuration file found is used)" << std::endl << " -h, --help Print this help message and exit" << std::endl << " -d, --debug Print more logs for label operations" << std::endl << - " -f, --force Force labeling for not-blank tapes for testing purpose and without label checks. Must only be used manually." << std::endl; + " -f, --force Force labeling for not-blank tapes for testing purpose and without label checks. Must only be used manually." << std::endl; } } // namespace cta::tapeserver::tapelabel diff --git a/tapeserver/tapelabel/TapeLabelCmdLineArgs.hpp b/tapeserver/tapelabel/TapeLabelCmdLineArgs.hpp index c18b046ddc..7b1da886e6 100644 --- a/tapeserver/tapelabel/TapeLabelCmdLineArgs.hpp +++ b/tapeserver/tapelabel/TapeLabelCmdLineArgs.hpp @@ -30,18 +30,18 @@ struct TapeLabelCmdLineArgs { /** * True if the usage message should be printed. */ - bool help; - + bool help = false; + /** * The tape VID to be pre-label. */ std::string m_vid; - + /** * The old label on tape to be checked when pre-labeling. */ std::string m_oldLabel; - + /** * The unit name of the drive used to mount the tape. */ @@ -49,14 +49,14 @@ struct TapeLabelCmdLineArgs { /** * The boolean variable to enable verbose output in the command line. - * By default it prints only ERR and WARNING messages. - */ - bool m_debug; - + * By default it prints only ERR and WARNING messages. + */ + bool m_debug = false; + /** - * The boolean variable to skip label checks on not-blank tapes. - */ - bool m_force; + * The boolean variable to skip label checks on not-blank tapes. + */ + bool m_force = false; /** * The timeout to load the tape in the drive slot in seconds diff --git a/tests/ImmutableFileTestCmdLineArgs.cpp b/tests/ImmutableFileTestCmdLineArgs.cpp index 478c67fa0c..74ca6b33cb 100644 --- a/tests/ImmutableFileTestCmdLineArgs.cpp +++ b/tests/ImmutableFileTestCmdLineArgs.cpp @@ -26,8 +26,7 @@ namespace cta { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -ImmutableFileTestCmdLineArgs::ImmutableFileTestCmdLineArgs(const int argc, char *const *const argv): - help(false) { +ImmutableFileTestCmdLineArgs::ImmutableFileTestCmdLineArgs(const int argc, char *const *const argv) { static struct option longopts[] = { {"help", no_argument, nullptr, 'h'}, diff --git a/tests/ImmutableFileTestCmdLineArgs.hpp b/tests/ImmutableFileTestCmdLineArgs.hpp index bdf1f331d8..df858afc40 100644 --- a/tests/ImmutableFileTestCmdLineArgs.hpp +++ b/tests/ImmutableFileTestCmdLineArgs.hpp @@ -30,7 +30,7 @@ struct ImmutableFileTestCmdLineArgs { /** * True if the usage message should be printed. */ - bool help; + bool help = false; /** * The XRootd URL of the file to be modified. -- GitLab