From 70bfe34c39f6ba0f56f2761a67312377c104c8c7 Mon Sep 17 00:00:00 2001 From: Yuan Jing Vincent Yan Date: Mon, 14 Oct 2024 14:19:12 -0400 Subject: [PATCH] [Fix] m_bmqstoragetool::FileManagerImpl: Asserts not have side effects (#461) Signed-off-by: Yuan Jing Vincent Yan --- .../bmqstoragetool/m_bmqstoragetool_filemanager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_filemanager.cpp b/src/applications/bmqstoragetool/m_bmqstoragetool_filemanager.cpp index 1e3040168..698ee84c1 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_filemanager.cpp +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_filemanager.cpp @@ -129,8 +129,10 @@ QueueMap FileManagerImpl::buildQueueMap(const bsl::string& cslFile, cslFile.c_str()); bsl::string pattern(alloc); bsl::string location(alloc); - BSLS_ASSERT(bdls::PathUtil::getBasename(&pattern, cslFile) == 0); - BSLS_ASSERT(bdls::PathUtil::getDirname(&location, cslFile) == 0); + int rc = bdls::PathUtil::getBasename(&pattern, cslFile); + BSLS_ASSERT(rc == 0); + rc = bdls::PathUtil::getDirname(&location, cslFile); + BSLS_ASSERT(rc == 0); ledgerConfig.setLocation(location) .setPattern(pattern) .setMaxLogSize(fileSize) @@ -145,7 +147,10 @@ QueueMap FileManagerImpl::buildQueueMap(const bsl::string& cslFile, // Create and open the ledger mqbsl::Ledger ledger(ledgerConfig, alloc); - BSLS_ASSERT(ledger.open(mqbsi::Ledger::e_READ_ONLY) == 0); + rc = ledger.open(mqbsi::Ledger::e_READ_ONLY); + BSLS_ASSERT(rc == 0); + (void)rc; // Compiler happiness + // Set guard to close the ledger bdlb::ScopeExitAny guard(bdlf::BindUtil::bind(closeLedger, &ledger));