Skip to content

Commit

Permalink
[Fix] m_bmqstoragetool::FileManagerImpl: Asserts not have side effects (
Browse files Browse the repository at this point in the history
#461)

Signed-off-by: Yuan Jing Vincent Yan <yyan82@bloomberg.net>
  • Loading branch information
kaikulimu authored Oct 14, 2024
1 parent 07fa5d1 commit 70bfe34
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/applications/bmqstoragetool/m_bmqstoragetool_filemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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));

Expand Down

0 comments on commit 70bfe34

Please sign in to comment.