diff --git a/catalogue/dummy/DummyCatalogue.cpp b/catalogue/dummy/DummyCatalogue.cpp index cda07c67902dd6f6f23d851146c21bd817ca1da9..356a1ec164c0201806245f980c7ac357c4342e0d 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 be3df3d2258ccce4b804b7d8e22af533e2101b55..1bce6385b26bb619def8ecf853479f5eea39716b 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 063e1a21f71a60fd030168db78313979712a0957..123b8c2a01f88fa4fb498402c980cbef912d5fc5 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 8c0b6f57632c5b367d1c00c002609780614888b7..3c440782a878aecdc24ab406949e3885ece98f07 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 6df46a974da00af9f9a3738274d07fcca59d7866..d8414024423c6182402145a105c416fef5aeef0b 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 d59e94248a7d61ec404bac89ac1433ff3c4e637c..e1b438b321eafdc7c96ffa4636359000ad40c3ab 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 e8ff58b17524a28312ba03c858f7a774974ec11e..a87923179c419047489673110c90305239f67951 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 bd2f722a3d8aaa73f2649a13c8841c8c392b4ba1..8327eef82ba29411fcf950056ea5d6921ddfd7cf 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 d1340c0dc0060506b7b404d185499aba98a2847c..fabefa481bb0e70a183588a84ce82801e9937a22 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 46fcca8443795521aa78d53d2cb86120235fcef2..ab79f1593e1f27de2dddb3816df058dffee852dc 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 765c503a9d60f1cf0061a053ec731a72c54380f5..025fa17eff8634dadc2fc7ec940374d26d048155 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 5a1a1e4ea910781524ff87c5522eaf87d2883f4f..f0a3b007da9d83478bb1a1c4779a2662ffa17f27 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 8eb230a5b0f4532cc92a40da210cfe84666514c2..fae90698b2c9993b836e414c0b07d4ed69eea741 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 94a5e5da2ffa11dcd8632ec27179d6fd24e6506d..64a8858bf808290323f7863ab86518e1fe344059 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 965953acbed8b5de43688887c76b1ffb2bec2d8a..080d23d07cd17e1eb2ea86192a81168a8dcca672 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 ef5221b80fdfad52718bf13898131cf061c15a6e..28d032b88ebb7de42c2ac2632c4f53b6574d9e47 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 e005e3b1c6be373cbd07ef268bf6b8880b711f96..14c4b5a724d1dc532f71976ebc483454f32a7d9b 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 539642322e6b492f556bf2b10a0f9febe01d65b2..cbf6d19ab99f7f9fec460399e8f729cabf0abf0b 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 4eb0fcefca5a6bc31fdad136610a035d61f55611..5941a708e85169b0216ac1509d8748bc26258aa9 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 588f734f822cb07a5f0aaa2a9324e86454431a26..81f764e5b9b6a35dee2882b2146764f7d4efdec9 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 e756dee0a96ff2cecefecd306a0b816211f7cb0d..2bad6cb39c1139040da896d2dcd592ab1ad25793 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 ce7acba86be876c314e967234b3fab4168ac3924..60161802837f1eaa60c4132240d03cdffa7af627 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 b3100dd0d9bf2779e595ff9f12615cc1ccfc89f1..a02d50b0dba10f45bbab733ad7003143a44b182d 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 e8606fd265c53ab5e2b57c0b9a6daf6933f25df1..b3355defdc03b83ba97ff427cd56a566a8ccd9ab 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 93ccc4604a56f3e2b54c66f58d6a1f95cf7118d1..2a24c406249f711405e7a715d8473cc164916906 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 6d3989a4d80230cd76b5b14b63eaa13079b176a1..836dc43d6a23d1367f57e9f171dede7e9cae98a2 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 42193891c724fe1e8264a7a8c0e3fa3e73622b3d..b24770d591758c1d9bdcf57e8850313c1a226846 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 132fc9e73baebe569af043cfb70a983ca8d1b549..8fd35c21db37891c7a7ef9af8c960d1f52294aea 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 a1e857de3e45964b0bcce295a6bd676c06c90bd1..1e743bfd11f93a94f0fca7e49bd26997ef951b3d 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 39cb159c7878c12725f00ebf652c8125add8790f..05510e1c05c988ec9500f40f7f44e6ade51110e7 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 a84e032d36faa8ccab5dd9416c26828ad15a1d01..842ef70e9a1c44eb414fbf79a4b0e7f9e4e79b69 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 d4556ca6760322b8a5fdc88248f6633fed88d0db..3ad5cb98b5b7cd40b7f8d6daf01eb999d5300046 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 e843e24843cab58604cf9442fddd32174969ad34..1f82d658c4c0404ae332a82630fcd41742ded1ef 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 6468dae980cde35fc983288ae1b00ccff6111e8a..66eef31651d6b5a7e26205fc9cdc993af336b278 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 3eccc11538773835cabf85775ee18d81a12d6433..f434d61a66b059c871218dbb5eb6f234b7de842c 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 6e087708e4e9c5994cedcbadc84b318916531b9e..e7c4e494b2734be16c01b454eb8b4df200fca1b6 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 8479eb004f92c8b3765b06ada63165091be05fa6..48a08190ac2e894c0c920818a1dd6b6c1cd38b94 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 4710c9a335cb0540e47b77cec350a62a095794fa..63de695962ddaff52dcb0034c3954f8c3deab2de 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 cc2024771699c8d12c3a1142eee0a658b27d23b4..85788fc3342c8c27f9141a9a11cb4878f57c9322 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 9147f478fcf46c8d68b7e3cb7234eb3eb7ec543d..18b163fdc15971938fa83c184fea04ec1a0f7b87 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 826d597fb57f78a311b7634aedccfa892ec4e54d..ad0c94764407ce9723cdc6e9e7b5bcbc0eddfe17 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 c08a8f3533b25e96ca684c16152f18a369ad7d60..a902b19acc807470be6fe71982e9d01331027ae8 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 33feb13e770209c11cbe67845d28fd6d7ac4c5cf..7b36a2549d8abf84bb0c5fe640f8f35a892e8e51 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 0491c8562805ac3a979d021a2e2a12703e6ed289..a9e150b0f20edc24550b7dd9c35e52f5c2f251af 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 667b9ec620297d0fb97b85b30dfe6afa53dcdf2e..47fd81967914ede43420d43077cd3ebef6eac1d1 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 34b2d072532699ba448818efcc1625f3fbc99f3b..de321a48d3b2079171e8a1845effc76bb7de7994 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 65f069e8a45ae948504bf53a5d13533845dfd1b6..c6d3b06446d6c889b5eba50e638198ed30314346 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 1d4dc90e971b5c2679592555be106072c6a6bb53..c9dbb8aefa0ef5c10a1aa5676f77b23b76ee1039 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 062f321b9ea2f5e52d7ea04e75cd6e0c0554777a..5d8b4eb7d59fe79aa25536399c866ff5fd34a0a9 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 e12f6da5d4ea52df3180010e13b403ec26c6df85..e7fb8b298f9c33d4f863d20848ccf48a573d548b 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 034664433db7a506f3ccb567d456f8aeea67c081..497807fa4c2927b096f01c9c9795f32f0aaa8c72 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 2022bd65fb2c41fd6a05a014ab79ba8891edd8bf..327176476c750a0807824c0f0e529c17455ca572 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 9b94977d3c7a9a9b0de80bf9482a1e906b0a444d..600fcf9fde0fb5c2e960e4df30e27d0fbca11bd8 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 753ad3fe24593b473771362faef4d5c7b4530d9c..55916f1a43939433a3aaa07fe4e7a3a5aa57b2da 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 ca96df295681b0f6c4e02f1b680662442e44e048..7b6372f858b10e6bfe6503606f0912a026c318f7 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 1d7708825e36500f1dfbcb9265d215b710ba2f12..15c7f3ed6e0b899d3b374b7aa445feb13655a1f7 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 f94b7aeb99344517c7ac692e9ad4f974161791ac..a6f2b462e3c35ca76e175eb32b4608dfed1a9050 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 35c7baa51dc7bcb54d3bf23d8639c656ffa1f475..75395971b34b5330e7ac492a30f3a536a480514e 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 b00b18be264cac754f39f1d14cf0a172b97b8405..e1c0862cd14145dd04bce210e3f06e628a5af4e8 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 dd078e438dde27e43ab63598d34fe53c77aa563e..08e43933a51156cd2dc68bc76a80f00944a994d9 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 9fca64c4aa228102dd9ee44fc25b841740a4656a..3503e4b12605da4e1f7da49b315748731c78d3c7 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 a51c7fa610720fc67b3587424abd79142b50a5f9..055a33fd11cd2f039912189493a238219b7935d2 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 2ad5cc16899ab5023903dd1b22d0f1d116ab9c41..f43589e06d862d62d7aadc23a3185fb05887c741 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 515e1d4268239b83c7ffdd43af58e17db9b272a7..b6cefc111df850b6517d70919997cde86cc75263 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 8aca92bc8a6ad442a573d6ee1a257cbaf2a1c98c..c1dfb0fbc8b0bf2420a3c9e167577a72a00feab1 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 42d847529ffe9db031b9dc506ca4e300e9fe66f6..97c35b517b794680949bcf440df3cf1cf335ab4b 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 bf0303c29a521b4feec1f6b4cacffaa39113eb2f..85efe281ec138924f25045da4699e5002d7a4a6a 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 6bcd743946c2209604be50a0f15d29a9ac5fc943..bcadc3855f53aee6f9382590186363810ea0635e 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 09ba5d379bd2e7eac9020f440aee5fc6feec1e1e..6ca0c352e100e6119f806dc6e2f67ae40d38c208 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 22771011999cffe306d5d25428cc608afa3aefc1..6f371326891dbf3f0f7cd8b5abc8df0d8a52634b 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 7f77970f86c4ff6caf89edc63b60c8f347404613..082f68fb4c7ff811c33be6754e9bf4ee37bd6cef 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 985d629d2be8851332fdcba153977a6b9c2a5f74..8c7c072ca0503d2ffc0f7da4fe3c40037c985086 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 5741549904150bc50909f584065902fb751d2a7f..ea0e8733e66a4e2c2dbf8de73bc828bbc5093d81 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 b86c2c52f7e4ae6785b74a005e3c51b4c75b062e..b606ca4cd7b79b4c8ecc72013ae1436de9d6acaa 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 c9a2efeeecbc1832708240f19530fc4d888293ff..b305c132f930375a735de551de3d27aceeff68cd 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 5d5109d406b2014807a013053e24e64a4238d950..1c82e9c32d237ddd88107c8056135a312fd05e48 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 16dfd8bf0667944f6a77d801b588b0d0f0f4a64a..c0440de9f27409944fa6a83a01e5a09e1b4a02e0 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 37ebbbda70c5df812138c5d9901297a0fed31d62..302ac723d3de6be753a2e0c24fac5e7193b109fa 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 cfcd352b32306fddd0d2b200df4bb41ac30fb712..868fa4a1e7e2a7c397d834c86946c705a9cac136 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 14ca781b6cfff3c8d7e505386ba5340c815936c5..67e01a8f342823bd77ee0fc7fce0b1036b0724f2 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 95bfd3ed2e1fee578c7c49511b5e99726353eb78..f4fb12585937ca08c2fa7af47d4071dbaf2b5965 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 b04e4d5fd5ad1974ef555c3b18fb5d2e19f8371b..f600ac0c812fbe7163253ce3ea9273c5bd33ea22 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 346bdf0b06f2bcf62b949d38107f6193f948d815..82e574f6b568ac404c6a08132604106d9e9de748 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 e5cc5a55856db9d59879502063fbc672e7186d26..0201b4f8f6d9721e2653ffd8d7e7c9cc79a40a6d 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 19e611762e44c62f3ffbf55e05270099b5d4582b..daefd99c4534cf02935780e960b2764c9d23b4dc 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 3ef703ed375f46bb53375ba6ccf3b83d46dd8c45..fc75971a36c5f8dac621e3e8688ca8c0354b811c 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 f365ad92c74303bc87a5e194ab78e53363ddb07f..b73c0e44df591a03950aa67a25809f40a1eef859 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 2855489739f0916ff9c5627704845eb8d12004fe..de5b1ceb069aeb50ed05907bb8ab65f212f06953 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 00a711443d2b29ae5ab1d9085bb7d7f5ca30986e..c0f3097054df4938ae007f551b2773f789aa4e64 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 c77722be86fe937fc18831a41e1b0583d8b46f78..2f40bba544ef9d0852d2d490230ee33ae4159682 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 b861624adc2f98b811bb66361ac9d1f38e1a2ae7..7e5e77fff1fd1396ffe371bdea6bf9523c18c160 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 f914e7cc5dbb1e0042221e57779eb4ce024c8560..f96513cabb5856ce80d8f7c8a835d100062bdf0c 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 138e6229c2ba8c251c75d21783db4bf9df3a1b31..a95f4743d65bf23c670c2adaf9b47ec1e43c8aad 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 0e5b8e0675c87a6fa17b0604ddd6fde79a0ecb4f..f3dde39da85997309e7437e4286895cb1ffe2e8d 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 3ba3f325e21a5271eb034626b05ca8124c580341..dd39246d8a2952aa6b7833144b8cbf402ceca5d5 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 cc4647a7cae3a335bcb99c1b626bc96fee094549..3b3aa0dc1ae9e6f8b9b95bde192e61fc3eae7ff7 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 1cc026cbc731790ef0a74f347e30d7b5ed035d40..d23c952416d6158fb6f32ba956ae51edebb56505 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 e5caecfb1dd5e6abd32004625848fb2fbb67620a..6d530287af74a3d917bcce1c0598dd9b0581bcc8 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 03309f2dbd6e4f8ee3a8c73aa67d14d3d92a0a2d..bc51c32c25cdcfc4388103ed8116ffac24be2eb9 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 52fa3a45e1d2e1be206f8bba7af4d41531dddab7..775217dc327ff86a7f43b605e2297155480ddab6 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 04b0488fadff8bf52bae8f93b5797dc25ef9c663..234099375297533e10043703072d15d95f7bb69e 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 69fd8e5d379eee017e4372b0616a684fdfa8918b..4fab3e57f782e6f98d2679752cf77378fdcf07ce 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 433b391b09e72693c28a2e8644b327407314a2da..0382c6d826203104efafdffac5348665021d8ac6 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 5b4d394244cf5bd4b4a7fefe84ae0f465fb88cf4..eb80c6250bbac0379b5342308314ea513f85f6bf 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 f0938af589f0593a39effd2448c46183dc80bf95..857baddc0a169b6ac8d396a34a61219bd6a3aef8 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 20775c36e359d0a9a14b92ef18598ce0be69bb95..fe5cc35e1361b4958b011ea3f6573f32bc74d0d1 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 20ebfc8dffdb5e4760b5c64dea2bb77aecece6d8..e4c636b7e6a2fa3b30139aa2597d7f0db1682847 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 d82f3cebb8ee091b3dd72797c22eda72664e7bdf..e17460edfdb3b2d7d41ea6a330cdb67b99df6b5c 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 f143805432663e2c8267000f3fa11a971da45047..09dc94a4a025c6a4ad6f783f9655caf4e35e9cdc 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 42b1146ee52b960b69b4af64719fe0f621a04d2f..921a18f4064002772cd316e1aedb798ec536819c 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 35d52f665232cc965ec7ea00ea5bf72d514ae4c5..c5280934a96720d746dbb10e15a966eb084eaba8 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 f4e0b52519bef353a996e7a580950ef8611a1469..eed2b5e3e4e1cd980b7b5c026002af4a92bdc69c 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 c9f476869c0cc34a897047e70c0201d2ec8faf88..5dc8161cc8f66d58c68a19d72c64f598d7a74289 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 cfd747223c639729a32c2a2f9d07e1d097a064c6..f8759748e7979d88f1e36d311afebe02f4285a9d 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 95120fb01a55cc2d32e70437152d6626d1e5b8f1..ac71bc4d990dfa2567de154485ca0b93b87a8620 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 f517abee137d608f2ea833c524820d7385d1421b..036a61e299868ed25ed99aea31de189eaa6d2a41 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 dd647b511194a890897751712b88dab70b5c93bc..3fa52aaf45b43528f569bd50762a428686d53831 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 c336ea7393d5a4d0e0d80b8ce4122e030a39bf62..601c3ad87cd186221ea598e930ede02543c6bafa 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 1704f0335d3c1dcc8fdc1df1ae8e291f11d655b0..b343438e7fc9a8448628645c4bb05e143913c91f 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 2743409fedc8ffe836095de3692fdb8576f798b5..9ab1abc7c3ad576c61791a250e9941c868d8da9f 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 249d48c3c609508704e7d842ce3bcd9c08b046b6..315e84604b36b48849c61549ac72bd9b976e4ac7 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 ee4a907c9005e3b1db8d1664371e680667eacef8..e3f63b4b671a854562f3367ae6077b2fa7a290bf 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 f1e9a049e182a5256a7ff19b4589a78a09a42616..edf47f586d3c491da60f9e2dd3da20d605a6ef73 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 869eefac7a99ca813e2cc76ba8b9c441a5056673..e450aeb60c93fb788e5bd382cdf69aabe5b2d1e4 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 cf3e17f86907dafe70aff7d79138d2c9002b6c97..720bb2038d7b9bd8f729536d583e3f6f29001415 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 1e0c781f498538496caa3bf1c6ba9989ef39c5b2..d32db7ec7612f277f97bc0a3fc4c7017e9155ca1 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 dcb1263643a9d070c611a0ab79959025907827b9..8502e32b234db21f0754f6a1bb0017e93fe0480e 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 ff474288a597bc3bb7ade0ec6a993685a3fb5834..2a4f54e37763431f557a5635355d4bfbfca63f45 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 725f5a723d1ee77647b4a2a65bdd532d69620b48..3e83ea64305244ff8a5f89c24a9dc3de344372cf 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 7128e044a74a6dea9b71e4542550f88c69a3a437..fb43579a4c42c441d4c884f61886c036faf04743 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 3b52335b3747ba998d11a4adf8a55288f6abee57..970e871936f0388c441408bbe5c70477695af716 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 693da2038be36689a22a6bb667afddc4de62b6aa..24f745ee6e23a219c03dc8255b7849e13a29c83a 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 b16fa994c349a9e21700c20b88df7e1882e94a12..7950b7a46009180a0263f4c5b3b5b2bf8943d162 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 2081e8a4a2a92a4ad7ca74da773c7224bb0b2fbf..bc11609b074e0ca155ac5494f1f6d2971576bee2 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 d21cc8c921b21a96a326aa7bf4ac2ed547d9e782..27fafe4494d89db7f11811297ae11faf8bd55876 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 e39c5ca21c56c547fbd5e498218de5f60c8f7432..53312e3e07ac830ad4d27564295795878f990731 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 b09599d133c77daabd90ff4a2168f30b36b3adbe..ba1ba5b20a1ff607c22e9093a2336b72574fd464 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 22483fa1568ba7d00e7934ff3c91b4e085cbbfa4..0307983dc25a28c2c3d2d9496c98d24c9977ca7b 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 fc5e1f5038ea85b0ead751232d47327f7b429d6b..2bdb10792892ae2f98acb11991b66b6d1c6407cd 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 f58c7a30a064db0ae4fe4812ea9ebfcc763dcc4c..3a60dd1f877a678cccac5505de9f3ee113553635 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 9acf55481b2b6eade15abcae3db01d4cb4cd793f..e711f770fe33646138e6cb158a4305af47accbcf 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 7043598cd33750c48ecf3ee74e87b1950669085b..9414cb1d6e3fce85e2b5acb93a635ebcc89ae0c9 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 c18b046ddc38f269c199246c098fb4206586e061..7b1da886e6df3ae2ecc0db9d99717f0a58b15268 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 478c67fa0c0152c78eb0c3fd1a567c990bdb7439..74ca6b33cbda97803ca943da0f26c61e659413ba 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 bdf1f331d882e75471fb21c7c23884bba5f0546c..df858afc40b6c38589e989d392b0abae04f52b8a 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.