From ec30722517d1939f3b76a52e443ae581be01635c Mon Sep 17 00:00:00 2001 From: CVales Date: Wed, 29 Apr 2026 20:15:51 +0200 Subject: [PATCH 1/2] Modernize DpCatalog: in-class initializers and =default dtor Resolves several static analysis findings from #4521 in Svc/DpCatalog: - 22x cpp:S3230 ("Do not use the constructor's initializer list for data member ...; use the in-class initializer instead"). All scalar and pointer members previously initialized in the constructor's member-initializer list are now default-initialized in the class body of DpCatalog.hpp. - 1x cpp:S3490 ("Use =default instead of the default implementation of this special member function"). The empty destructor is now declared = default in the header. Behavior is unchanged: members are still initialized in declaration order, which matched the previous initializer-list order, so the construction sequence is identical. Object members (m_directories[], m_fileList[], m_stateFile, m_currXmitFileName) are unchanged because they are default-constructed and were not flagged by SonarQube. Aligned with the in-class initializer style already used elsewhere in the repo (e.g. Svc/DpWriter, Svc/SeqDispatcher, Svc/Ccsds/AosFramer). --- Svc/DpCatalog/DpCatalog.cpp | 27 +------------------ Svc/DpCatalog/DpCatalog.hpp | 52 ++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 52 deletions(-) diff --git a/Svc/DpCatalog/DpCatalog.cpp b/Svc/DpCatalog/DpCatalog.cpp index 30f43253018..86d2ef32b8b 100644 --- a/Svc/DpCatalog/DpCatalog.cpp +++ b/Svc/DpCatalog/DpCatalog.cpp @@ -21,32 +21,7 @@ static_assert(DP_MAX_FILES > 0, "Configuration DP_MAX_FILES must be positive"); // Component construction and destruction // ---------------------------------------------------------------------- -DpCatalog ::DpCatalog(const char* const compName) - : DpCatalogComponentBase(compName), - m_initialized(false), - m_dpTree(nullptr), - m_freeListHead(nullptr), - m_currentNode(nullptr), - m_currentXmitNode(nullptr), - m_numDpSlots(0), - m_numDirectories(0), - m_stateFileData(nullptr), - m_stateFileEntries(0), - m_memSize(0), - m_memPtr(nullptr), - m_allocatorId(0), - m_allocator(nullptr), - m_catalogBuilt(false), - m_xmitInProgress(false), - m_xmitCmdWait(false), - m_xmitBytes(0), - m_xmitOpCode(0), - m_xmitCmdSeq(0), - m_pendingFiles(0), - m_pendingDpBytes(0), - m_remainActive(false) {} - -DpCatalog ::~DpCatalog() {} +DpCatalog ::DpCatalog(const char* const compName) : DpCatalogComponentBase(compName) {} void DpCatalog::configure(Fw::FileNameString directories[DP_MAX_DIRECTORIES], FwSizeType numDirs, diff --git a/Svc/DpCatalog/DpCatalog.hpp b/Svc/DpCatalog/DpCatalog.hpp index d477912df86..2d6e473093e 100644 --- a/Svc/DpCatalog/DpCatalog.hpp +++ b/Svc/DpCatalog/DpCatalog.hpp @@ -34,7 +34,7 @@ class DpCatalog final : public DpCatalogComponentBase { ); /// @brief DpCatalog destructor - ~DpCatalog(); + ~DpCatalog() = default; /// @brief Configure the DpCatalog /// @param maxDpFiles The max number of data product files to track @@ -243,42 +243,42 @@ class DpCatalog final : public DpCatalogComponentBase { // ---------------------------------- // Private data // ---------------------------------- - bool m_initialized; //!< set when the component has been initialized + bool m_initialized = false; //!< set when the component has been initialized - DpBtreeNode* m_dpTree; //!< The head of the binary tree - DpBtreeNode* m_freeListHead; //!< The head of the free list - DpBtreeNode* m_currentNode; //!< current node for traversing tree - DpBtreeNode* m_currentXmitNode; //!< node being currently transmitted + DpBtreeNode* m_dpTree = nullptr; //!< The head of the binary tree + DpBtreeNode* m_freeListHead = nullptr; //!< The head of the free list + DpBtreeNode* m_currentNode = nullptr; //!< current node for traversing tree + DpBtreeNode* m_currentXmitNode = nullptr; //!< node being currently transmitted - FwSizeType m_numDpSlots; //!< Stores the available number of record slots. + FwSizeType m_numDpSlots = 0; //!< Stores the available number of record slots. Fw::FileNameString m_directories[DP_MAX_DIRECTORIES]; //!< List of supplied DP directories - FwSizeType m_numDirectories; //!< number of supplied directories + FwSizeType m_numDirectories = 0; //!< number of supplied directories Fw::String m_fileList[DP_MAX_FILES]; //!< working array of files/directory - Fw::FileNameString m_stateFile; //!< file to store transmit state - DpDstateFileEntry* m_stateFileData; //!< DP state loaded from file - FwSizeType m_stateFileEntries; //!< size of state file data + Fw::FileNameString m_stateFile; //!< file to store transmit state + DpDstateFileEntry* m_stateFileData = nullptr; //!< DP state loaded from file + FwSizeType m_stateFileEntries = 0; //!< size of state file data - FwSizeType m_memSize; //!< size of allocated buffer - void* m_memPtr; //!< stored for shutdown - FwEnumStoreType m_allocatorId; //!< stored for shutdown - Fw::MemAllocator* m_allocator; //!< stored for shutdown + FwSizeType m_memSize = 0; //!< size of allocated buffer + void* m_memPtr = nullptr; //!< stored for shutdown + FwEnumStoreType m_allocatorId = 0; //!< stored for shutdown + Fw::MemAllocator* m_allocator = nullptr; //!< stored for shutdown - bool m_catalogBuilt; //!< catalog build is complete (can add DPs at runtime) - bool m_xmitInProgress; //!< set if DP files are in the process of being sent + bool m_catalogBuilt = false; //!< catalog build is complete (can add DPs at runtime) + bool m_xmitInProgress = false; //!< set if DP files are in the process of being sent Fw::FileNameString m_currXmitFileName; //!< current file being transmitted - bool m_xmitCmdWait; //!< true if waiting for transmission complete to complete xmit command - U64 m_xmitBytes; //!< bytes transmitted for downlink session - FwOpcodeType m_xmitOpCode; //!< stored xmit command opcode - U32 m_xmitCmdSeq; //!< stored command sequence id + bool m_xmitCmdWait = false; //!< true if waiting for transmission complete to complete xmit command + U64 m_xmitBytes = 0; //!< bytes transmitted for downlink session + FwOpcodeType m_xmitOpCode = 0; //!< stored xmit command opcode + U32 m_xmitCmdSeq = 0; //!< stored command sequence id - U32 m_pendingFiles; //!< Pending Files to Transmit - U64 m_pendingDpBytes; //!< Pending Bytes to Transmit + U32 m_pendingFiles = 0; //!< Pending Files to Transmit + U64 m_pendingDpBytes = 0; //!< Pending Bytes to Transmit - bool m_remainActive; //!< Does the DpCat resume transmission when - //!< a runtime Dp is received after - //!< the full catalog is sent + bool m_remainActive = false; //!< Does the DpCat resume transmission when + //!< a runtime Dp is received after + //!< the full catalog is sent }; } // namespace Svc From 2fc14d364c59eca874319fe54791a08b426f62d8 Mon Sep 17 00:00:00 2001 From: CVales Date: Wed, 29 Apr 2026 20:42:48 +0200 Subject: [PATCH 2/2] DpCatalog: move constructor body off the signature line Addresses CodeQL "More than one statement per line" alert introduced by the previous commit, which collapsed the constructor signature and the empty body onto the same line. Adds an explanatory comment inside the body to keep it on its own line; clang-format would otherwise re-collapse the empty `{}` under the repo's Chromium-based style. Behavior unchanged. --- Svc/DpCatalog/DpCatalog.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Svc/DpCatalog/DpCatalog.cpp b/Svc/DpCatalog/DpCatalog.cpp index 86d2ef32b8b..cf55aef5c06 100644 --- a/Svc/DpCatalog/DpCatalog.cpp +++ b/Svc/DpCatalog/DpCatalog.cpp @@ -21,7 +21,9 @@ static_assert(DP_MAX_FILES > 0, "Configuration DP_MAX_FILES must be positive"); // Component construction and destruction // ---------------------------------------------------------------------- -DpCatalog ::DpCatalog(const char* const compName) : DpCatalogComponentBase(compName) {} +DpCatalog ::DpCatalog(const char* const compName) : DpCatalogComponentBase(compName) { + // Members are default-initialized via in-class initializers in the header. +} void DpCatalog::configure(Fw::FileNameString directories[DP_MAX_DIRECTORIES], FwSizeType numDirs,