From 2878d169ba6bd2e4dfc3e33ff90e0e7d46f9259f Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 28 Nov 2025 17:00:52 +0100 Subject: [PATCH 1/3] Adds explicit to constructors --- catalogue/TapeItemWrittenPointer.hpp | 5 +- common/exception/ChecksumBlobSizeMismatch.hpp | 2 +- common/exception/ChecksumTypeMismatch.hpp | 2 +- common/exception/ChecksumValueMismatch.hpp | 2 +- common/exception/CommandLineNotParsed.hpp | 17 +- common/exception/EncryptionException.hpp | 14 +- common/exception/Errnum.hpp | 2 +- common/exception/Exception.hpp | 2 +- common/exception/FileSizeMismatch.hpp | 16 +- common/exception/GrpcError.hpp | 12 +- common/exception/NonRetryableError.hpp | 19 +-- common/exception/NotImplementedException.hpp | 8 +- common/exception/NullPtrException.hpp | 12 +- common/exception/TapeFseqMismatch.hpp | 16 +- common/exception/UserError.hpp | 18 +-- common/exception/UserErrorWithCacheInfo.hpp | 26 ++- common/threading/AtomicFlag.hpp | 4 +- disk/DiskFile.hpp | 2 +- disk/DiskFileImplementations.hpp | 4 +- frontend/grpc/FrontendGrpcService.hpp | 2 +- .../callback_api/ServerDefaultReactor.hpp | 4 +- mediachanger/RmcProxy.hpp | 4 +- objectstore/ArchiveQueueAlgorithms.hpp | 4 +- objectstore/ObjectOps.hpp | 2 +- objectstore/RetrieveQueueAlgorithms.hpp | 4 +- rdbms/Conn.hpp | 148 ++++++++---------- rdbms/DBException.hpp | 17 +- rdbms/InvalidResultSet.hpp | 2 +- rdbms/NullDbValue.hpp | 16 +- scheduler/rdbms/postgres/Transaction.hpp | 2 +- .../castor/tape/tapeserver/SCSI/Exception.hpp | 2 +- .../daemon/MigrationReportPacker.hpp | 4 +- .../tape/tapeserver/drive/FakeDrive.hpp | 5 +- 33 files changed, 161 insertions(+), 238 deletions(-) diff --git a/catalogue/TapeItemWrittenPointer.hpp b/catalogue/TapeItemWrittenPointer.hpp index 3daab445a5..644322db74 100644 --- a/catalogue/TapeItemWrittenPointer.hpp +++ b/catalogue/TapeItemWrittenPointer.hpp @@ -27,11 +27,12 @@ namespace cta::catalogue { */ struct TapeItemWrittenPointer : public std::unique_ptr { template - TapeItemWrittenPointer(Ts... args) : std::unique_ptr::unique_ptr(args...) {} + explicit TapeItemWrittenPointer(Ts... args) : + std::unique_ptr::unique_ptr(args...) {} }; // This operator (and not the member one) should be defined to be picked up by std::less, // which will define the ordering of std::set. bool operator<(const TapeItemWrittenPointer& a, const TapeItemWrittenPointer& b); -} // namespace cta::catalogue +} // namespace cta::catalogue diff --git a/common/exception/ChecksumBlobSizeMismatch.hpp b/common/exception/ChecksumBlobSizeMismatch.hpp index 57864cc552..f071d0a48d 100644 --- a/common/exception/ChecksumBlobSizeMismatch.hpp +++ b/common/exception/ChecksumBlobSizeMismatch.hpp @@ -32,7 +32,7 @@ public: * @param context optional context string added to the message at initialisation time * @param embedBacktrace whether to embed a backtrace of where the exception was thrown in the message */ - ChecksumBlobSizeMismatch(const std::string &context = "", const bool embedBacktrace = true) : + explicit ChecksumBlobSizeMismatch(const std::string &context = "", const bool embedBacktrace = true) : Exception(context, embedBacktrace) {} /** diff --git a/common/exception/ChecksumTypeMismatch.hpp b/common/exception/ChecksumTypeMismatch.hpp index 2fde7c4ecd..c122e5a852 100644 --- a/common/exception/ChecksumTypeMismatch.hpp +++ b/common/exception/ChecksumTypeMismatch.hpp @@ -34,7 +34,7 @@ public: * @param embedBacktrace whether to embed a backtrace of where the * exception was throw in the message */ - ChecksumTypeMismatch(const std::string &context = "", const bool embedBacktrace = true) : + explicit ChecksumTypeMismatch(const std::string &context = "", const bool embedBacktrace = true) : Exception(context, embedBacktrace) {} /** diff --git a/common/exception/ChecksumValueMismatch.hpp b/common/exception/ChecksumValueMismatch.hpp index ee5751a8e9..9dc452a8ed 100644 --- a/common/exception/ChecksumValueMismatch.hpp +++ b/common/exception/ChecksumValueMismatch.hpp @@ -34,7 +34,7 @@ public: * @param embedBacktrace whether to embed a backtrace of where the * exception was throw in the message */ - ChecksumValueMismatch(const std::string &context = "", const bool embedBacktrace = false) : + explicit ChecksumValueMismatch(const std::string &context = "", const bool embedBacktrace = false) : Exception(context, embedBacktrace) {} /** diff --git a/common/exception/CommandLineNotParsed.hpp b/common/exception/CommandLineNotParsed.hpp index 7f8c08a7b4..c0c14d2fe4 100644 --- a/common/exception/CommandLineNotParsed.hpp +++ b/common/exception/CommandLineNotParsed.hpp @@ -27,16 +27,13 @@ namespace cta::exception { class CommandLineNotParsed : public cta::exception::Exception { public: /** - * Constructor. + * Constructor * - * @param context optional context string added to the message - * at initialisation time. - * @param embedBacktrace whether to embed a backtrace of where the - * exception was throw in the message + * @param context optional context string added to the message at initialisation time + * @param embedBacktrace whether to embed a backtrace of where the exception was thrown in the message */ - CommandLineNotParsed(const std::string& context = "", const bool embedBacktrace = true) - : Exception(context, embedBacktrace) {} + explicit CommandLineNotParsed(const std::string& context = "", const bool embedBacktrace = true) : + Exception(context, embedBacktrace) {} +}; -}; // class CommandLineNotParsed - -} // namespace cta::exception +} // namespace cta::exception diff --git a/common/exception/EncryptionException.hpp b/common/exception/EncryptionException.hpp index 75cf0e7d6a..fe362ddbf9 100644 --- a/common/exception/EncryptionException.hpp +++ b/common/exception/EncryptionException.hpp @@ -22,16 +22,12 @@ namespace cta::exception { /** - * Failed to dismount volume. + * Failed to dismount volume */ class EncryptionException : public cta::exception::Exception { public: - /** - * Constructor - */ - EncryptionException(const std::string& context, const bool embedBacktrace = false) - : cta::exception::Exception(context, embedBacktrace) {} + explicit EncryptionException(const std::string& context, const bool embedBacktrace = false) : + cta::exception::Exception(context, embedBacktrace) {} +}; -}; // class DismountFailed - -} // namespace cta::exception +} // namespace cta::exception diff --git a/common/exception/Errnum.hpp b/common/exception/Errnum.hpp index 768f8f075f..41dc92a147 100644 --- a/common/exception/Errnum.hpp +++ b/common/exception/Errnum.hpp @@ -24,7 +24,7 @@ namespace cta::exception { class Errnum : public Exception { public: explicit Errnum(std::string_view what = ""); - Errnum(int err, std::string_view what = ""); + explicit Errnum(int err, std::string_view what = ""); ~Errnum() final = default; int errorNumber() const { return m_errnum; } diff --git a/common/exception/Exception.hpp b/common/exception/Exception.hpp index 10ac798c72..8b0dbdc041 100644 --- a/common/exception/Exception.hpp +++ b/common/exception/Exception.hpp @@ -36,7 +36,7 @@ public: * @param context optional context string added to the message at initialisation time * @param embedBacktrace whether to embed a backtrace of where the exception was thrown */ - Exception(std::string_view context = "", bool embedBacktrace = true); + explicit Exception(std::string_view context = "", bool embedBacktrace = true); /** * Copy constructor diff --git a/common/exception/FileSizeMismatch.hpp b/common/exception/FileSizeMismatch.hpp index 0208bdd98f..b4efb935cf 100644 --- a/common/exception/FileSizeMismatch.hpp +++ b/common/exception/FileSizeMismatch.hpp @@ -27,20 +27,14 @@ namespace cta::catalogue { class FileSizeMismatch: public exception::Exception { public: /** - * Constructor. + * Constructor * - * @param context optional context string added to the message - * at initialisation time. - * @param embedBacktrace whether to embed a backtrace of where the - * exception was throw in the message + * @param context optional context string added to the message at initialisation time + * @param embedBacktrace whether to embed a backtrace of where the exception was thrown in the message */ - FileSizeMismatch(const std::string &context = "", const bool embedBacktrace = true): - cta::exception::Exception(context, embedBacktrace) { - } + explicit FileSizeMismatch(const std::string &context = "", const bool embedBacktrace = true) : + cta::exception::Exception(context, embedBacktrace) {} - /** - * Destructor - */ ~FileSizeMismatch() override = default; }; diff --git a/common/exception/GrpcError.hpp b/common/exception/GrpcError.hpp index 444b491c46..eb5ca18019 100644 --- a/common/exception/GrpcError.hpp +++ b/common/exception/GrpcError.hpp @@ -23,12 +23,8 @@ namespace cta::exception { class GrpcError : public cta::exception::Exception { public: - /** - * Constructor - */ - GrpcError(const std::string& context, const bool embedBacktrace = true) - : cta::exception::Exception(context, embedBacktrace) {} + explicit GrpcError(const std::string& context, const bool embedBacktrace = true) : + cta::exception::Exception(context, embedBacktrace) {} +}; -}; // class GrpcError - -} // namespace cta::exception +} // namespace cta::exception diff --git a/common/exception/NonRetryableError.hpp b/common/exception/NonRetryableError.hpp index daff97e12f..44372ca87f 100644 --- a/common/exception/NonRetryableError.hpp +++ b/common/exception/NonRetryableError.hpp @@ -22,21 +22,18 @@ namespace cta::exception { /** - * An exception class representing an application error that should not be retried. + * An exception class representing an application error that should not be retried */ class NonRetryableError : public exception::Exception { public: /** - * Constructor. + * Constructor * - * @param context optional context string added to the message - * at initialisation time. - * @param embedBacktrace whether to embed a backtrace of where the - * exception was throw in the message + * @param context optional context string added to the message at initialisation time + * @param embedBacktrace whether to embed a backtrace of where the exception was thrown in the message */ - NonRetryableError(const std::string& context = "", const bool embedBacktrace = true) - : Exception(context, embedBacktrace) {} + explicit NonRetryableError(const std::string& context = "", const bool embedBacktrace = true) : + Exception(context, embedBacktrace) {} +}; -}; // class UserError - -} // namespace cta::exception +} // namespace cta::exception diff --git a/common/exception/NotImplementedException.hpp b/common/exception/NotImplementedException.hpp index 08a6e27328..596835836e 100644 --- a/common/exception/NotImplementedException.hpp +++ b/common/exception/NotImplementedException.hpp @@ -27,10 +27,8 @@ namespace cta::exception { */ class NotImplementedException : public cta::exception::Exception { public: - /** - * default constructor - */ - NotImplementedException(const std::string& what = "") : cta::exception::Exception() {} + explicit NotImplementedException(const std::string& what = "") : + cta::exception::Exception() {} }; -} // namespace cta::exception +} // namespace cta::exception diff --git a/common/exception/NullPtrException.hpp b/common/exception/NullPtrException.hpp index 945912b2be..74fd13534d 100644 --- a/common/exception/NullPtrException.hpp +++ b/common/exception/NullPtrException.hpp @@ -17,20 +17,14 @@ #pragma once -// Include Files #include "common/exception/Exception.hpp" namespace cta::exception { -/** - * Null pointer exception - */ class NullPtrException : public cta::exception::Exception { public: - /** - * default constructor - */ - NullPtrException(const std::string& context = "") : cta::exception::Exception(context) {} + explicit NullPtrException(const std::string& context = "") : + cta::exception::Exception(context) {} }; -} // namespace cta::exception +} // namespace cta::exception diff --git a/common/exception/TapeFseqMismatch.hpp b/common/exception/TapeFseqMismatch.hpp index 6a61af37f8..b364f08383 100644 --- a/common/exception/TapeFseqMismatch.hpp +++ b/common/exception/TapeFseqMismatch.hpp @@ -22,25 +22,19 @@ namespace cta::exception { /** - * Exception representing an unexpected mismatch between tape file sequence - * numbers. + * Exception representing an unexpected mismatch between tape file sequence numbers */ class TapeFseqMismatch: public exception::Exception { public: /** - * Constructor. + * Constructor * - * @param context optional context string added to the message - * at initialisation time. - * @param embedBacktrace whether to embed a backtrace of where the - * exception was throw in the message + * @param context optional context string added to the message at initialisation time + * @param embedBacktrace whether to embed a backtrace of where the exception was thrown in the message */ - TapeFseqMismatch(const std::string &context = "", const bool embedBacktrace = true) : + explicit TapeFseqMismatch(const std::string &context = "", const bool embedBacktrace = true) : Exception(context, embedBacktrace) {} - /** - * Destructor - */ ~TapeFseqMismatch() override = default; }; diff --git a/common/exception/UserError.hpp b/common/exception/UserError.hpp index b4a44d1ce7..976c88cf9b 100644 --- a/common/exception/UserError.hpp +++ b/common/exception/UserError.hpp @@ -22,22 +22,20 @@ namespace cta::exception { /** - * An exception class representng a user as opposed to an application error. + * An exception class representng a user as opposed to an application error */ class UserError : public exception::Exception { public: /** - * Constructor. + * Constructor * - * @param context optional context string added to the message - * at initialisation time. - * @param embedBacktrace whether to embed a backtrace of where the - * exception was throw in the message + * @param context optional context string added to the message at initialisation time + * @param embedBacktrace whether to embed a backtrace of where the exception was thrown in the message */ - UserError(const std::string& context = "", const bool embedBacktrace = true) : Exception(context, embedBacktrace) {} + explicit UserError(const std::string& context = "", const bool embedBacktrace = true) : + Exception(context, embedBacktrace) {} +}; -}; // class UserError - -} // namespace cta::exception +} // namespace cta::exception #define CTA_GENERATE_USER_EXCEPTION_CLASS(A) class A: public cta::exception::UserError { using UserError::UserError; } diff --git a/common/exception/UserErrorWithCacheInfo.hpp b/common/exception/UserErrorWithCacheInfo.hpp index e3b788dcc2..96b393da9a 100644 --- a/common/exception/UserErrorWithCacheInfo.hpp +++ b/common/exception/UserErrorWithCacheInfo.hpp @@ -22,27 +22,21 @@ namespace cta::exception { /** - * A user error together with information about how the respective cached - * value was obtained. + * A user error together with information about how the respective cached value was obtained */ class UserErrorWithCacheInfo : public exception::UserError { public: - std::string cacheInfo; - /** - * Constructor. + * Constructor * - * @param cInfo Information about how the respective cached value was - * obtained. - * @param context optional context string added to the message - * at initialisation time. - * @param embedBacktrace whether to embed a backtrace of where the - * exception was throw in the message + * @param cInfo Information about how the respective cached value was obtained + * @param context optional context string added to the message at initialisation time + * @param embedBacktrace whether to embed a backtrace of where the exception was thrown in the message */ - UserErrorWithCacheInfo(const std::string &cInfo, const std::string &context = "", const bool embedBacktrace = true): - UserError(context, embedBacktrace), - cacheInfo(cInfo) { - } -}; // class UserErrorWithTimeBasedCacheInfo + explicit UserErrorWithCacheInfo(const std::string& cInfo, const std::string& context = "", const bool embedBacktrace = true) : + UserError(context, embedBacktrace), cacheInfo(cInfo) {} + + std::string cacheInfo; +}; } // namespace cta::exception diff --git a/common/threading/AtomicFlag.hpp b/common/threading/AtomicFlag.hpp index 22ac544b67..9efdd3c7bc 100644 --- a/common/threading/AtomicFlag.hpp +++ b/common/threading/AtomicFlag.hpp @@ -28,10 +28,10 @@ struct AtomicFlag { void set() { m_set = true; } - operator bool() const { return m_set; } + explicit operator bool() const { return m_set; } private: std::atomic m_set = false; }; -} // namespace cta::threading +} // namespace cta::threading diff --git a/disk/DiskFile.hpp b/disk/DiskFile.hpp index 753ad3fe24..69e2683e9d 100644 --- a/disk/DiskFile.hpp +++ b/disk/DiskFile.hpp @@ -48,7 +48,7 @@ namespace cta::disk { class DiskFileFactory { using Regex = cta::utils::Regex; public: - DiskFileFactory(uint16_t xrootTimeout); + explicit DiskFileFactory(uint16_t xrootTimeout); ReadFile * createReadFile(const std::string & path); WriteFile * createWriteFile(const std::string & path); private: diff --git a/disk/DiskFileImplementations.hpp b/disk/DiskFileImplementations.hpp index ca96df2956..cc820f8fe5 100644 --- a/disk/DiskFileImplementations.hpp +++ b/disk/DiskFileImplementations.hpp @@ -76,7 +76,7 @@ namespace cta::disk { class XrootReadFile: public XrootBaseReadFile { public: - XrootReadFile(const std::string &xrootUrl, uint16_t timeout = 0); + explicit XrootReadFile(const std::string& xrootUrl, uint16_t timeout = 0); }; class XrootBaseWriteFile: public WriteFile { @@ -96,7 +96,7 @@ namespace cta::disk { class XrootWriteFile: public XrootBaseWriteFile { public: - XrootWriteFile(const std::string &xrootUrl, uint16_t timeout = 0); + explicit XrootWriteFile(const std::string& xrootUrl, uint16_t timeout = 0); }; //============================================================================== diff --git a/frontend/grpc/FrontendGrpcService.hpp b/frontend/grpc/FrontendGrpcService.hpp index 996ac15ecc..e8a5230643 100644 --- a/frontend/grpc/FrontendGrpcService.hpp +++ b/frontend/grpc/FrontendGrpcService.hpp @@ -38,7 +38,7 @@ private: std::shared_ptr m_pubkeyCache; public: - CtaRpcImpl(const std::string& config); + explicit CtaRpcImpl(const std::string& config); FrontendService& getFrontendService() const { return *m_frontendService; } diff --git a/frontend/grpc/callback_api/ServerDefaultReactor.hpp b/frontend/grpc/callback_api/ServerDefaultReactor.hpp index 6108b5e841..cb23e1c461 100644 --- a/frontend/grpc/callback_api/ServerDefaultReactor.hpp +++ b/frontend/grpc/callback_api/ServerDefaultReactor.hpp @@ -10,7 +10,7 @@ namespace cta::frontend::grpc { class DefaultWriteReactor : public ::grpc::ServerWriteReactor { public: - DefaultWriteReactor(const std::string& errMsg, ::grpc::StatusCode errCode = ::grpc::StatusCode::INVALID_ARGUMENT) { + explicit DefaultWriteReactor(const std::string& errMsg, ::grpc::StatusCode errCode = ::grpc::StatusCode::INVALID_ARGUMENT) { Finish(Status(errCode, errMsg)); } @@ -21,4 +21,4 @@ void DefaultWriteReactor::OnDone() { delete this; } -} // namespace cta::frontend::grpc \ No newline at end of file +} // namespace cta::frontend::grpc diff --git a/mediachanger/RmcProxy.hpp b/mediachanger/RmcProxy.hpp index bc15713225..18aa75963d 100644 --- a/mediachanger/RmcProxy.hpp +++ b/mediachanger/RmcProxy.hpp @@ -45,9 +45,7 @@ public: * @parm maxRqstAttempts The maximum number of attempts a retriable RMC * request should be issued. */ - RmcProxy( - const uint16_t rmcPort = RMC_PORT, - const uint32_t netTimeout = RMC_NET_TIMEOUT, + explicit RmcProxy(const uint16_t rmcPort = RMC_PORT, const uint32_t netTimeout = RMC_NET_TIMEOUT, const uint32_t maxRqstAttempts = RMC_MAX_RQST_ATTEMPTS); /** diff --git a/objectstore/ArchiveQueueAlgorithms.hpp b/objectstore/ArchiveQueueAlgorithms.hpp index c53ae9d9e6..7e3ed4015a 100644 --- a/objectstore/ArchiveQueueAlgorithms.hpp +++ b/objectstore/ArchiveQueueAlgorithms.hpp @@ -482,7 +482,7 @@ template<> struct ContainerTraits::PopCriteria { uint64_t files; uint64_t bytes; - PopCriteria(uint64_t f = 0, uint64_t b = 0) : files(f), bytes(b) {} // cppcheck-suppress uninitMemberVar + explicit PopCriteria(uint64_t f = 0, uint64_t b = 0) : files(f), bytes(b) {} // cppcheck-suppress uninitMemberVar template PopCriteria& operator-=(const PoppedElementsSummary_t &pes) { bytes -= pes.bytes; @@ -495,7 +495,7 @@ template<> struct ContainerTraits::PoppedElementsSummary { uint64_t files; uint64_t bytes; - PoppedElementsSummary(uint64_t f = 0, uint64_t b = 0) : files(f), bytes(b) {} + explicit PoppedElementsSummary(uint64_t f = 0, uint64_t b = 0) : files(f), bytes(b) {} bool operator< (const PopCriteria & pc) { // This returns false if bytes or files are equal but the other value is less. Is that the intended behaviour? return bytes < pc.bytes && files < pc.files; diff --git a/objectstore/ObjectOps.hpp b/objectstore/ObjectOps.hpp index 346bdf0b06..e0bd41b553 100644 --- a/objectstore/ObjectOps.hpp +++ b/objectstore/ObjectOps.hpp @@ -385,7 +385,7 @@ class ScopedExclusiveLock: public ScopedLock { public: ScopedExclusiveLock() = default; - ScopedExclusiveLock(ObjectOpsBase & oo, uint64_t timeout_us = 0) { + explicit ScopedExclusiveLock(ObjectOpsBase& oo, uint64_t timeout_us = 0) { lock(oo, timeout_us); } diff --git a/objectstore/RetrieveQueueAlgorithms.hpp b/objectstore/RetrieveQueueAlgorithms.hpp index 90452c5b25..a759a6092b 100644 --- a/objectstore/RetrieveQueueAlgorithms.hpp +++ b/objectstore/RetrieveQueueAlgorithms.hpp @@ -466,7 +466,7 @@ template<> struct ContainerTraits::PopCriteria { uint64_t files; uint64_t bytes; - PopCriteria(uint64_t f = 0, uint64_t b = 0) : files(f), bytes(b) {} // cppcheck-suppress uninitMemberVar + explicit PopCriteria(uint64_t f = 0, uint64_t b = 0) : files(f), bytes(b) {} // cppcheck-suppress uninitMemberVar template PopCriteria& operator-=(const PoppedElementsSummary_t &pes) { bytes -= pes.bytes; @@ -487,7 +487,7 @@ struct ContainerTraits::PoppedElementsSum uint64_t bytes; bool diskSystemFull = false; std::string fullDiskSystem; - PoppedElementsSummary(uint64_t f = 0, uint64_t b = 0) : files(f), bytes(b) {} // cppcheck-suppress uninitMemberVar + explicit PoppedElementsSummary(uint64_t f = 0, uint64_t b = 0) : files(f), bytes(b) {} // cppcheck-suppress uninitMemberVar bool operator==(const PoppedElementsSummary &pes) const { return bytes == pes.bytes && files == pes.files; } diff --git a/rdbms/Conn.hpp b/rdbms/Conn.hpp index 9dd0913cc9..54fae2803f 100644 --- a/rdbms/Conn.hpp +++ b/rdbms/Conn.hpp @@ -31,206 +31,183 @@ class ConnPool; /** * A smart database connection that will automatically return the underlying - * database connection to its parent connection pool when it goes out of scope. + * database connection to its parent connection pool when it goes out of scope */ class Conn { public: - - /** - * Constructor. - */ Conn(); /** - * Constructor. + * Constructor * - * @param connAndStmts The database connection and its pool of prepared - * statements. - * @param pool The database connection pool to which the connection - * should be returned. + * @param connAndStmts The database connection and its pool of prepared statements + * @param pool The database connection pool to which the connection should be returned */ Conn(std::unique_ptr connAndStmts, ConnPool *const pool); /** - * Deletion of the copy constructor. + * Deletion of the copy constructor */ - Conn(Conn &) = delete; + Conn(Conn&) = delete; /** - * Move constructor. + * Move constructor * - * @param other The other object. + * @param other The other object */ - Conn(Conn &&other) noexcept; + Conn(Conn&& other) noexcept; /** - * Destructor. + * Destructor * - * Returns the database connection back to its pool. + * Returns the database connection back to its pool */ ~Conn() noexcept; /** - * Returns the database connection back to its pool. + * Returns the database connection back to its pool * - * This method is idempotent. + * This method is idempotent */ void reset() noexcept; /** - * Deletion of the copy assignment operator. + * Deletion of the copy assignment operator */ - Conn &operator=(const Conn &) = delete; + Conn& operator=(const Conn&) = delete; /** - * Move assignment operator. + * Move assignment operator * - * @param rhs The object on the right-hand side of the operator. - * @return This object. + * @param rhs The object on the right-hand side of the operator + * @return This object */ - Conn &operator=(Conn &&rhs) noexcept; + Conn& operator=(Conn&& rhs) noexcept; /** - * Thrown when a requested autocommit mode is not supported. + * Thrown when a requested autocommit mode is not supported */ struct AutocommitModeNotSupported: public exception::Exception { - AutocommitModeNotSupported(const std::string &context = "", const bool embedBacktrace = true): + explicit AutocommitModeNotSupported(const std::string &context = "", const bool embedBacktrace = true) : Exception(context, embedBacktrace) {} }; /** - * Sets the autocommit mode of the connection. + * Sets the autocommit mode of the connection * - * @param autocommitMode The autocommit mode of the connection. - * @throw AutocommitModeNotSupported If the specified autocommit mode is not - * supported. + * @param autocommitMode The autocommit mode of the connection + * @throw AutocommitModeNotSupported If the specified autocommit mode is not supported */ void setAutocommitMode(const AutocommitMode autocommitMode); /** - * Returns the autocommit mode of the connection. + * Returns the autocommit mode of the connection * - * @return The autocommit mode of the connection. + * @return The autocommit mode of the connection */ AutocommitMode getAutocommitMode() const; /** - * Creates a prepared statement. + * Creates a prepared statement * - * @param sql The SQL statement. - * @return The prepared statement. + * @param sql The SQL statement + * @return The prepared statement */ Stmt createStmt(const std::string &sql); /** - * Executes the statement. + * Executes the statement * - * @param sql The SQL statement. + * @param sql The SQL statement */ void executeNonQuery(const std::string &sql); /** - * Commits the current transaction. + * Commits the current transaction */ void commit(); /** - * Rolls back the current transaction. + * Rolls back the current transaction */ void rollback(); /** - * Returns the names of all the column and their type as a map for the given - * table in the database schema. + * Returns the names of all the column and their type as a map for the given table in the database schema * - * @param tableName The table name to get the columns. - * @return The map of types by name of all the columns for the given table in the database schema. + * @param tableName The table name to get the columns + * @return The map of types by name of all the columns for the given table in the database schema */ std::map> getColumns(const std::string &tableName) const; /** - * Returns the names of all the tables in the database schema in alphabetical - * order. + * Returns the names of all the tables in the database schema in alphabetical order * - * @return The names of all the tables in the database schema in alphabetical - * order. + * @return The names of all the tables in the database schema in alphabetical order */ std::list getTableNames() const; /** - * Returns the names of all the indices in the database schema in alphabetical - * order. + * Returns the names of all the indices in the database schema in alphabetical order * - * @return The names of all the indices in the database schema in alphabetical - * order. + * @return The names of all the indices in the database schema in alphabetical order */ std::list getIndexNames() const; /** - * Closes the underlying cached database statements and their connection. + * Closes the underlying cached database statements and their connection * - * This method should only be used in extreme cases where the closure of thei - * underlying database connection needs to be forced. + * This method should only be used in extreme cases where the closure of the + * underlying database connection needs to be forced */ void closeUnderlyingStmtsAndConn(); /** - * Returns true if this connection is open. + * Returns true if this connection is open */ bool isOpen() const; /** - * Returns the names of all the sequences in the database schema in - * alphabetical order. + * Returns the names of all the sequences in the database schema in alphabetical order * - * If the underlying database technologies does not supported sequences then - * this method simply returns an empty list. + * If the underlying database technologies does not supported sequences then this method simply returns an empty list * - * @return The names of all the sequences in the database schema in - * alphabetical order. + * @return The names of all the sequences in the database schema in alphabetical order */ std::list getSequenceNames(); /** - * Returns the names of all the triggers in the database schema in - * alphabetical order. + * Returns the names of all the triggers in the database schema in alphabetical order * - * If the underlying database technologies does not supported triggers then - * this method simply returns an empty list. + * If the underlying database technologies does not supported triggers then this method simply returns an empty list * - * @return The names of all the triggers in the database schema in - * alphabetical order. + * @return The names of all the triggers in the database schema in alphabetical order */ std::list getTriggerNames(); /** - * Returns the names of all the tables that have been set as PARALLEL - * in alphabetical order. + * Returns the names of all the tables that have been set as PARALLEL in alphabetical order * - * If the underlying database technologies does not support PARALLEL - * them this method simply returns an empty list. + * If the underlying database technologies does not support PARALLEL them this method simply returns an empty list * - * @return the names of all the tables that have been set as PARALLEL - * in alphabetical order. + * @return the names of all the tables that have been set as PARALLEL in alphabetical order */ std::list getParallelTableNames(); /** * Returns the Constraint names of a given table in the database schema * - * If the underlying database technologies does not support constraints informations - * this method simply returns an empty list. + * If the underlying database technologies does not support constraints informations this method simply returns an empty list * * @param tableName the table name to get the constraint names from - * @return the list of the names of the constraints that the given table has. + * @return the list of the names of the constraints that the given table has */ std::list getConstraintNames(const std::string &tableName); /** * Returns the stored procedure names of the database * - * If the underlying database technologies does not support stored procedures informations - * this method simply returns an empty list. + * If the underlying database technologies does not support stored procedures informations this method simply returns an empty list * * @return the list of the names of the stored procedures in the database */ @@ -239,8 +216,7 @@ public: /** * Returns the synonym names of the database * - * If the underlying database technologies does not support synonym informations - * this method simply returns an empty list. + * If the underlying database technologies does not support synonym informations this method simply returns an empty list * * @return the list of the names of the synonyms in the database */ @@ -249,8 +225,7 @@ public: /** * Returns the type names of the database * - * If the underlying database technologies does not support type informations - * this method simply returns an empty list. + * If the underlying database technologies does not support type informations this method simply returns an empty list * * @return the list of the names of the types in the database */ @@ -259,8 +234,7 @@ public: /** * Returns the view names of the database * - * If the underlying database technologies does not support type informations - * this method simply returns an empty list. + * If the underlying database technologies does not support type informations this method simply returns an empty list * * @return the list of the names of the views in the database */ @@ -278,12 +252,12 @@ public: private: /** - * The database connection and its pool of prepared statements. + * The database connection and its pool of prepared statements */ std::unique_ptr m_connAndStmts; /** - * The database connection pool to which the m_conn should be returned. + * The database connection pool to which the m_conn should be returned */ ConnPool *m_pool; diff --git a/rdbms/DBException.hpp b/rdbms/DBException.hpp index ece80029cc..77ee3df0b7 100644 --- a/rdbms/DBException.hpp +++ b/rdbms/DBException.hpp @@ -25,24 +25,21 @@ namespace cta::rdbms { /** - * A database constraint error. + * A database constraint error */ class DBException : public cta::exception::Exception { public: /** - * Constructor. + * Constructor * - * @param context optional context string added to the message - * at initialisation time. - * @param embedBacktrace whether to embed a backtrace of where the - * exception was throw in the message + * @param context optional context string added to the message at initialisation time + * @param embedBacktrace whether to embed a backtrace of where the exception was throw in the message */ - DBException(const std::string &context = "", const std::string &dbErrorMessage="", const bool embedBacktrace = true); + explicit DBException(const std::string& context = "", const std::string& dbErrorMessage="", const bool embedBacktrace = true); /** - * Empty Destructor, explicitely non-throwing (needed for std::exception - * inheritance) + * Empty Destructor, explicitely non-throwing (needed for std::exception inheritance) */ ~DBException() noexcept override = default; @@ -53,6 +50,6 @@ public: private: std::string rawDbErrorMessage; -}; // class DBException +}; } // namespace cta::rdbms diff --git a/rdbms/InvalidResultSet.hpp b/rdbms/InvalidResultSet.hpp index 2add76bd50..eea2ca593e 100644 --- a/rdbms/InvalidResultSet.hpp +++ b/rdbms/InvalidResultSet.hpp @@ -32,7 +32,7 @@ public: * @param context optional context string added to the message at initialisation time * @param embedBacktrace whether to embed a backtrace of where the exception was thrown in the message */ - InvalidResultSet(const std::string &context = "", const bool embedBacktrace = true) : + explicit InvalidResultSet(const std::string &context = "", const bool embedBacktrace = true) : Exception(context, embedBacktrace) {} /** diff --git a/rdbms/NullDbValue.hpp b/rdbms/NullDbValue.hpp index 5488ed35ac..2c30dda01d 100644 --- a/rdbms/NullDbValue.hpp +++ b/rdbms/NullDbValue.hpp @@ -23,21 +23,17 @@ namespace cta::rdbms { /** * An exception class representing an unexpected encounter with a nullptr database - * value (not to be confused with a nullptr C/C++ pointer). + * value (not to be confused with a nullptr C/C++ pointer) */ class NullDbValue: public exception::Exception { public: - /** - * Constructor. + * Constructor * - * @param context optional context string added to the message - * at initialisation time. - * @param embedBacktrace whether to embed a backtrace of where the - * exception was throw in the message + * @param context optional context string added to the message at initialisation time + * @param embedBacktrace whether to embed a backtrace of where the exception was thrown in the message */ - NullDbValue(const std::string &context = "", const bool embedBacktrace = true); - -}; // class NullDbValue + explicit NullDbValue(const std::string& context = "", const bool embedBacktrace = true); +}; } // namespace cta::rdbms diff --git a/scheduler/rdbms/postgres/Transaction.hpp b/scheduler/rdbms/postgres/Transaction.hpp index 62e35909c1..11e07e622f 100644 --- a/scheduler/rdbms/postgres/Transaction.hpp +++ b/scheduler/rdbms/postgres/Transaction.hpp @@ -26,7 +26,7 @@ public: CTA_GENERATE_EXCEPTION_CLASS(SQLError); // Constructors - Transaction(std::unique_ptr conn, bool ownConnection = false); + explicit Transaction(std::unique_ptr conn, bool ownConnection = false); explicit Transaction(cta::rdbms::ConnPool& connPool); // Move constructor diff --git a/tapeserver/castor/tape/tapeserver/SCSI/Exception.hpp b/tapeserver/castor/tape/tapeserver/SCSI/Exception.hpp index 533a2fb6fd..af11bf97e2 100644 --- a/tapeserver/castor/tape/tapeserver/SCSI/Exception.hpp +++ b/tapeserver/castor/tape/tapeserver/SCSI/Exception.hpp @@ -66,7 +66,7 @@ class UnitAttentionException : public castor::tape::SCSI::Exception { */ class HostException : public cta::exception::Exception { public: - HostException(const unsigned short int host_status, const std::string& context = ""); + explicit HostException(const unsigned short int host_status, const std::string& context = ""); ~HostException() final = default; }; diff --git a/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPacker.hpp b/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPacker.hpp index 4d6197bd48..8a88b8c485 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPacker.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPacker.hpp @@ -235,8 +235,8 @@ private: const std::string m_failureLog; public: - ReportLastBatchError(std::string& failureLog) - : m_failureLog(failureLog) {} + explicit ReportLastBatchError(std::string& failureLog) : + m_failureLog(failureLog) {} void execute(MigrationReportPacker& reportPacker) override; }; diff --git a/tapeserver/castor/tape/tapeserver/drive/FakeDrive.hpp b/tapeserver/castor/tape/tapeserver/drive/FakeDrive.hpp index 1e0c781f49..73f6dc4ff5 100644 --- a/tapeserver/castor/tape/tapeserver/drive/FakeDrive.hpp +++ b/tapeserver/castor/tape/tapeserver/drive/FakeDrive.hpp @@ -53,9 +53,8 @@ class FakeDrive : public DriveInterface { public: std::string contentToString() noexcept; - FakeDrive(uint64_t capacity = std::numeric_limits::max(), - enum FailureMoment failureMoment = OnWrite, - bool failOnMount = false) noexcept; + explicit FakeDrive(uint64_t capacity = std::numeric_limits::max(), + enum FailureMoment failureMoment = OnWrite, bool failOnMount = false) noexcept; explicit FakeDrive(bool failOnMount) noexcept; ~FakeDrive() override = default; compressionStats getCompression() final; -- GitLab From da843fd237c38583001664b6249df105f330c69a Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 28 Nov 2025 17:13:08 +0100 Subject: [PATCH 2/3] Reset TapeItemWrittenPointer --- catalogue/TapeItemWrittenPointer.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/catalogue/TapeItemWrittenPointer.hpp b/catalogue/TapeItemWrittenPointer.hpp index 644322db74..3daab445a5 100644 --- a/catalogue/TapeItemWrittenPointer.hpp +++ b/catalogue/TapeItemWrittenPointer.hpp @@ -27,12 +27,11 @@ namespace cta::catalogue { */ struct TapeItemWrittenPointer : public std::unique_ptr { template - explicit TapeItemWrittenPointer(Ts... args) : - std::unique_ptr::unique_ptr(args...) {} + TapeItemWrittenPointer(Ts... args) : std::unique_ptr::unique_ptr(args...) {} }; // This operator (and not the member one) should be defined to be picked up by std::less, // which will define the ordering of std::set. bool operator<(const TapeItemWrittenPointer& a, const TapeItemWrittenPointer& b); -} // namespace cta::catalogue +} // namespace cta::catalogue -- GitLab From c6cdc2c65d4df9a12234d157eaf06d75f6ce29ad Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 28 Nov 2025 17:26:33 +0100 Subject: [PATCH 3/3] Reverts AtomicFlag --- common/threading/AtomicFlag.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/threading/AtomicFlag.hpp b/common/threading/AtomicFlag.hpp index 9efdd3c7bc..22ac544b67 100644 --- a/common/threading/AtomicFlag.hpp +++ b/common/threading/AtomicFlag.hpp @@ -28,10 +28,10 @@ struct AtomicFlag { void set() { m_set = true; } - explicit operator bool() const { return m_set; } + operator bool() const { return m_set; } private: std::atomic m_set = false; }; -} // namespace cta::threading +} // namespace cta::threading -- GitLab