From 993e3d76befd87d77eb11a7cfbe96651cf8ba1e4 Mon Sep 17 00:00:00 2001 From: Taylor Foxhall Date: Fri, 6 Dec 2024 18:56:36 -0500 Subject: [PATCH] Fix several warnings m_bmqstoragetool ================ FileManager - Follow ISO C++ destructor rules FileManagerMock - Fix weak-vtable SearchShortResult - Remove unused d_allocator_p parameter - Add allocator() method to retrieve allocator from subobject bmq === bmqa_mocksession - Remove unused const overload of uriCorrIdToQueues bmqma_countingallocator - Properly mark CountingAllocator::configureStatContextTableInfoProvider as deprecated bmqtst_logcontroller - Add missing cases in switch statement mqb === mqba_commandrouter - Mark CommandRouter::ClusterWideRoutingMode::getRouteTargets errorDescription as unused - Move RoutingMode::~RoutingMode() to implementation file mqba_sessionnegotiator - Escape '@' character used by doxygen special command parsing mqbcfg_tcpinterfaceconfigvalidator - Add newline to end of header mqbi_queueengine - Mark QueueEngine::logAppSubscription appId as unused mqbmock_storagemanager - Force assertion failure for unimplemented StorageManager::fileStore mqbnet_tcpsessionfactory - Remove unused channelCast() helper Signed-off-by: Taylor Foxhall --- .../m_bmqstoragetool_filemanager.h | 2 +- .../m_bmqstoragetool_filemanagermock.cpp | 23 +++++++++++++++- .../m_bmqstoragetool_filemanagermock.h | 27 ------------------- .../m_bmqstoragetool_searchresult.cpp | 6 ++++- .../m_bmqstoragetool_searchresult.h | 6 +++-- src/groups/bmq/bmqa/bmqa_mocksession.cpp | 8 ------ .../bmq/bmqma/bmqma_countingallocator.h | 7 +++-- .../bmq/bmqtsk/bmqtsk_logcontroller.cpp | 1 + src/groups/mqb/mqba/mqba_commandrouter.cpp | 7 ++--- src/groups/mqb/mqba/mqba_commandrouter.h | 2 +- .../mqb/mqba/mqba_sessionnegotiator.cpp | 2 +- .../mqb/mqbblp/mqbblp_queueenginetester.h | 18 ++++++------- .../mqbcfg_tcpinterfaceconfigvalidator.h | 2 +- src/groups/mqb/mqbi/mqbi_queueengine.cpp | 10 ++++--- .../mqb/mqbmock/mqbmock_storagemanager.cpp | 1 + .../mqb/mqbnet/mqbnet_tcpsessionfactory.cpp | 19 ------------- 16 files changed, 62 insertions(+), 79 deletions(-) diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_filemanager.h b/src/applications/bmqstoragetool/m_bmqstoragetool_filemanager.h index 4d03ba80c..eefc5cce9 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_filemanager.h +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_filemanager.h @@ -127,7 +127,7 @@ inline FileManagerImpl::FileHandler::FileHandler( } template -inline FileManagerImpl::FileHandler::~FileHandler() +inline FileManagerImpl::FileHandler::~FileHandler() { d_iter.clear(); if (d_mfd.isValid()) { diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_filemanagermock.cpp b/src/applications/bmqstoragetool/m_bmqstoragetool_filemanagermock.cpp index 7cc459be4..d63cff5b7 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_filemanagermock.cpp +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_filemanagermock.cpp @@ -20,7 +20,28 @@ namespace BloombergLP { namespace m_bmqstoragetool { -// NOTHING +FileManagerMock::FileManagerMock() +: d_journalFileIt() +, d_dataFileIt() +{ + EXPECT_CALL(*this, dataFileIterator()) + .WillRepeatedly(testing::Return(&d_dataFileIt)); +} + +FileManagerMock::FileManagerMock(const JournalFile& journalFile) +: d_journalFileIt(&journalFile.mappedFileDescriptor(), + journalFile.fileHeader(), + false) +, d_dataFileIt() +{ + EXPECT_CALL(*this, dataFileIterator()) + .WillRepeatedly(testing::Return(&d_dataFileIt)); +} + +mqbs::JournalFileIterator* FileManagerMock::journalFileIterator() +{ + return &d_journalFileIt; +} } // close package namespace diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_filemanagermock.h b/src/applications/bmqstoragetool/m_bmqstoragetool_filemanagermock.h index c0084be13..c09d1579e 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_filemanagermock.h +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_filemanagermock.h @@ -98,33 +98,6 @@ class FileManagerMock : public FileManager { // INLINE DEFINITIONS // ============================================================================ -// ===================== -// class FileManagerMock -// ===================== - -inline FileManagerMock::FileManagerMock() -: d_journalFileIt() -, d_dataFileIt() -{ - EXPECT_CALL(*this, dataFileIterator()) - .WillRepeatedly(testing::Return(&d_dataFileIt)); -} - -inline FileManagerMock::FileManagerMock(const JournalFile& journalFile) -: d_journalFileIt(&journalFile.mappedFileDescriptor(), - journalFile.fileHeader(), - false) -, d_dataFileIt() -{ - EXPECT_CALL(*this, dataFileIterator()) - .WillRepeatedly(testing::Return(&d_dataFileIt)); -} - -inline mqbs::JournalFileIterator* FileManagerMock::journalFileIterator() -{ - return &d_journalFileIt; -} - } // close package namespace } // close enterprise namespace diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.cpp b/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.cpp index ce7b98bac..039d9fcb7 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.cpp +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.cpp @@ -311,11 +311,15 @@ SearchShortResult::SearchShortResult( , d_printedMessagesCount(0) , d_guidMap(allocator) , d_guidList(allocator) -, d_allocator_p(allocator) { // NOTHING } +bslma::Allocator* SearchShortResult::allocator() const +{ + return d_guidMap.get_allocator().mechanism(); +} + bool SearchShortResult::processMessageRecord( const mqbs::MessageRecord& record, BSLS_ANNOTATION_UNUSED bsls::Types::Uint64 recordIndex, diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.h b/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.h index 123241799..16da30901 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.h +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.h @@ -153,8 +153,6 @@ class SearchShortResult : public SearchResult { // Map to store guid and list iterator, for fast searching by guid. bsl::list d_guidList; // List to store ordered guid data to preserve messages order for output. - bslma::Allocator* d_allocator_p; - // Allocator used inside the class. // PRIVATE MANIPULATORS @@ -180,6 +178,10 @@ class SearchShortResult : public SearchResult { bool printOnDelete = false, bslma::Allocator* allocator = 0); + // ACCESSORS + + bslma::Allocator* allocator() const; + // MANIPULATORS /// Process `message` record with the specified `record`, `recordIndex` and diff --git a/src/groups/bmq/bmqa/bmqa_mocksession.cpp b/src/groups/bmq/bmqa/bmqa_mocksession.cpp index 753c5e46c..5433ec239 100644 --- a/src/groups/bmq/bmqa/bmqa_mocksession.cpp +++ b/src/groups/bmq/bmqa/bmqa_mocksession.cpp @@ -128,14 +128,6 @@ UriCorrIdToQueueMap& uriCorrIdToQueues(B& buffer) { return reinterpret_cast(*(buffer.buffer())); } - -/// Utility method to cast the `UriCorrIdToQueueMap` held by the -/// `bsls::AlignedBuffer` (represented by the type `B`). -template -const UriCorrIdToQueueMap& uriCorrIdToQueues(const B& buffer) -{ - return reinterpret_cast(*(buffer.buffer())); -} } // close unnamed namespace #define BMQA_CHECK_ARG(METHOD, ARGNAME, EXPECTED, ACTUAL, CALL) \ diff --git a/src/groups/bmq/bmqma/bmqma_countingallocator.h b/src/groups/bmq/bmqma/bmqma_countingallocator.h index 7f0b99dcd..e52cae398 100644 --- a/src/groups/bmq/bmqma/bmqma_countingallocator.h +++ b/src/groups/bmq/bmqma/bmqma_countingallocator.h @@ -78,6 +78,7 @@ #include #include #include +#include #include #include @@ -167,8 +168,10 @@ class CountingAllocator BSLS_KEYWORD_FINAL : public bslma::Allocator { /// Configure the specified `tableInfoProvider` with a filter, a /// comparator, and columns to print the statistics generated by this - /// `bmqma::CountingAllocator`. @DEPRECATED: use the version taking a - /// `bmqst::Table` and `bmqst::BasicTableInfoProvider` instead. + /// `bmqma::CountingAllocator`. + BSLS_DEPRECATE_FEATURE("bmq", + "configureStatContextTableInfoProvider", + "Use the alternate overload instead.") static void configureStatContextTableInfoProvider( bmqst::StatContextTableInfoProvider* tableInfoProvider); diff --git a/src/groups/bmq/bmqtsk/bmqtsk_logcontroller.cpp b/src/groups/bmq/bmqtsk/bmqtsk_logcontroller.cpp index 86128953e..44fa867bc 100644 --- a/src/groups/bmq/bmqtsk/bmqtsk_logcontroller.cpp +++ b/src/groups/bmq/bmqtsk/bmqtsk_logcontroller.cpp @@ -119,6 +119,7 @@ LogControllerConfig::balToBslsLogLevel(ball::Severity::Level level) case ball::Severity::e_INFO: return bsls::LogSeverity::e_INFO; case ball::Severity::e_DEBUG: return bsls::LogSeverity::e_DEBUG; case ball::Severity::e_TRACE: return bsls::LogSeverity::e_TRACE; + case ball::Severity::e_OFF: default: return bsls::LogSeverity::e_ERROR; }; } diff --git a/src/groups/mqb/mqba/mqba_commandrouter.cpp b/src/groups/mqb/mqba/mqba_commandrouter.cpp index 48fa28eb1..b69d7ef02 100644 --- a/src/groups/mqb/mqba/mqba_commandrouter.cpp +++ b/src/groups/mqb/mqba/mqba_commandrouter.cpp @@ -26,6 +26,7 @@ // BDE #include +#include namespace BloombergLP { namespace mqba { @@ -129,9 +130,9 @@ CommandRouter::ClusterWideRoutingMode::ClusterWideRoutingMode() } int CommandRouter::ClusterWideRoutingMode::getRouteTargets( - bsl::ostream& errorDescription, - RouteTargets* routeTargets, - mqbi::Cluster* cluster) + BSLA_MAYBE_UNUSED bsl::ostream& errorDescription, + RouteTargets* routeTargets, + mqbi::Cluster* cluster) { // PRECONDITIONS BSLS_ASSERT_SAFE(routeTargets); diff --git a/src/groups/mqb/mqba/mqba_commandrouter.h b/src/groups/mqb/mqba/mqba_commandrouter.h index adf21469a..74c9a9be5 100644 --- a/src/groups/mqb/mqba/mqba_commandrouter.h +++ b/src/groups/mqb/mqba/mqba_commandrouter.h @@ -113,7 +113,7 @@ class CommandRouter { class RoutingMode { public: RoutingMode(); - virtual ~RoutingMode() = 0; + virtual ~RoutingMode(); /// Populates the given `routeMembers` struct with the proper nodes to /// route to from the given `cluster`. Returns 0 on success or a diff --git a/src/groups/mqb/mqba/mqba_sessionnegotiator.cpp b/src/groups/mqb/mqba/mqba_sessionnegotiator.cpp index d7186ec05..436ee8bc6 100644 --- a/src/groups/mqb/mqba/mqba_sessionnegotiator.cpp +++ b/src/groups/mqb/mqba/mqba_sessionnegotiator.cpp @@ -208,7 +208,7 @@ void loadBrokerIdentity(bmqp_ctrlmsg::ClientIdentity* identity, /// Load in the specified `out` the short description representing the /// specified `identity` from the specified `peerChannel`. The format is as /// follow: -/// tskName:pid.sessionId[@hostId] +/// tskName:pid.sessionId[\@hostId] /// Where: /// - tskName : the task name, without any optional leading path /// - pid : the pid of the task diff --git a/src/groups/mqb/mqbblp/mqbblp_queueenginetester.h b/src/groups/mqb/mqbblp/mqbblp_queueenginetester.h index ea207a234..7c40b0f34 100644 --- a/src/groups/mqb/mqbblp/mqbblp_queueenginetester.h +++ b/src/groups/mqb/mqbblp/mqbblp_queueenginetester.h @@ -318,7 +318,7 @@ class QueueEngineTester { /// Obtain and return a handle for the client with handle parameters in /// the specified `clientText` per the following format: - /// `[@] [readCount=] [writeCount=]` + /// `[\@] [readCount=] [writeCount=]` /// /// The behavior is undefined unless `clientText` is formatted as above /// and includes at least one attribute (e.g. `readCount=1`) other than @@ -329,7 +329,7 @@ class QueueEngineTester { /// Configure the handle for the client with stream parameters in the /// specified `clientText` per the following format: - /// '[@] [consumerPriority=

] + /// '[\@] [consumerPriority=

] /// [consumerPriorityCount=] /// [maxUnconfirmedMessages=] /// [maxUnconfirmedBytes=]' @@ -338,7 +338,7 @@ class QueueEngineTester { /// on success, non-zero otherwise). The behavior is undefined unless /// `clientText` is formatted as above (e.g. 'C1 consumerPriority=1 /// consumerPriorityCount=2') , and a previous call to `getHandle()` - /// returned a handle for the `[@appId]`, or if + /// returned a handle for the `[\@appId]`, or if /// `createQueueEngine()` was not called. int configureHandle(const bsl::string& clientText); @@ -374,7 +374,7 @@ class QueueEngineTester { /// the client identified with the specified `clientText` for the /// specified `messages`. The format of `clientText` must be as /// follows: - /// `[@]` + /// `[\@]` /// /// The format of `messages` must be as follows: /// `,,...,` @@ -382,7 +382,7 @@ class QueueEngineTester { /// The order of confirming each message is from left to right per the /// format above. The behavior is undefined unless `messages` is /// formatted as above, and a previous call to `getHandle()` returned a - /// handle for the `[@appId]`, or if `createQueueEngine()` + /// handle for the `[\@appId]`, or if `createQueueEngine()` /// was not called. Note that it is "legal" for a client that is a /// reader to confirm a message that was not posted or that is already /// confirmed. @@ -393,7 +393,7 @@ class QueueEngineTester { /// the client identified with the specified `clientText` for the /// specified `messages`. The format of `clientText` must be as /// follows: - /// `[@]` + /// `[\@]` /// /// The format of `messages` must be as follows: /// `,,...,` @@ -401,7 +401,7 @@ class QueueEngineTester { /// The order of rejecting each message is from left to right per the /// format above. The behavior is undefined unless `messages` is /// formatted as above, and a previous call to `getHandle()` returned a - /// handle for the `[@appId]`, or if `createQueueEngine()` + /// handle for the `[\@appId]`, or if `createQueueEngine()` /// was not called. void reject(const bsl::string& clientText, const bslstl::StringRef& messages); @@ -427,7 +427,7 @@ class QueueEngineTester { /// Release the parameters in the handle of the client in the specified /// `clientText` per the following format: - /// `[@appId] [readCount=] [writeCount=]` + /// `[\@appId] [readCount=] [writeCount=]` /// /// Return the result status code of the releaseHandle operation (zero /// on success, non-zero otherwise). The behavior is undefined unless @@ -439,7 +439,7 @@ class QueueEngineTester { /// Release the parameters in the handle of the client in the specified /// `clientText` per the following format: - /// '[@appId] [readCount=] [writeCount=] + /// '[\@appId] [readCount=] [writeCount=] /// [isFinal=(true|false)]' /// /// Return the result status code of the releaseHandle operation (zero diff --git a/src/groups/mqb/mqbcfg/mqbcfg_tcpinterfaceconfigvalidator.h b/src/groups/mqb/mqbcfg/mqbcfg_tcpinterfaceconfigvalidator.h index 6ec1da8e5..c3f790501 100644 --- a/src/groups/mqb/mqbcfg/mqbcfg_tcpinterfaceconfigvalidator.h +++ b/src/groups/mqb/mqbcfg/mqbcfg_tcpinterfaceconfigvalidator.h @@ -82,4 +82,4 @@ class TcpInterfaceConfigValidator { } // close namespace mqbcfg } // close namespace BloombergLP -#endif \ No newline at end of file +#endif diff --git a/src/groups/mqb/mqbi/mqbi_queueengine.cpp b/src/groups/mqb/mqbi/mqbi_queueengine.cpp index 6509b7b97..112409ebd 100644 --- a/src/groups/mqb/mqbi/mqbi_queueengine.cpp +++ b/src/groups/mqb/mqbi/mqbi_queueengine.cpp @@ -17,9 +17,13 @@ #include #include + // BMQ #include +// BDE +#include + namespace BloombergLP { namespace mqbi { @@ -63,9 +67,9 @@ void QueueEngine::unregisterStorage( // NOTHING } -bsl::ostream& -QueueEngine::logAppSubscriptionInfo(bsl::ostream& stream, - const bsl::string& appId) const +bsl::ostream& QueueEngine::logAppSubscriptionInfo( + bsl::ostream& stream, + BSLA_MAYBE_UNUSED const bsl::string& appId) const { return stream; }; diff --git a/src/groups/mqb/mqbmock/mqbmock_storagemanager.cpp b/src/groups/mqb/mqbmock/mqbmock_storagemanager.cpp index 236cf17b3..cf4ff91c2 100644 --- a/src/groups/mqb/mqbmock/mqbmock_storagemanager.cpp +++ b/src/groups/mqb/mqbmock/mqbmock_storagemanager.cpp @@ -293,6 +293,7 @@ bool StorageManager::isStorageEmpty( const mqbs::FileStore& StorageManager::fileStore(BSLS_ANNOTATION_UNUSED int partitionId) const { + BSLS_ASSERT_INVOKE_NORETURN("Unimplemented"); } bslma::ManagedPtr diff --git a/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp b/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp index 12fddeaf5..3f5bb7e5d 100644 --- a/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp +++ b/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp @@ -262,25 +262,6 @@ struct PortMatcher { return listener.port() == d_port; } }; - -template -T* channelCast(bmqio::Channel* base) -{ - bmqio::Channel* alias = base; - while (alias) { - T* target = dynamic_cast(alias); - if (target) { - return target; - } - bmqio::DecoratingChannelPartialImp* decorated = - dynamic_cast(alias); - if (!decorated) { - return NULL; - } - alias = decorated->base(); - } -} - } // close unnamed namespace // -----------------------------------------