Skip to content

cppcheck: remove double semicolon generated with macro #968

@678098

Description

@678098

Overview

There are multiple cases in the codebase where ; is written explicitly and also added implicitly by macros. Example:

BMQU_THROTTLEDACTION_THROTTLE(
d_throttledFailedAckMessages,
BALL_LOG_ERROR
<< "Failed ACK for queue '" << queue->uri()
<< "' [status: "
<< bmqp::ProtocolUtil::ackResultFromCode(ackMsg.status())
<< ", GUID: " << ackMsg.messageGUID() << "]";);

This macro is expanded to
{ const bsls::Types::Int64 _now = BloombergLP::bsls::TimeUtil::getTimer(); if ((_now - d_throttledFailedAckMessages.d_lastResetTime) >= d_throttledFailedAckMessages.d_intervalNano) { int _numSkipped = d_throttledFailedAckMessages.d_countSinceLastReset; bsls::Types::Int64 _resetTime = d_throttledFailedAckMessages.d_lastResetTime; if (d_throttledFailedAckMessages.d_lastResetTime.testAndSwap(_resetTime, _now) == _resetTime) { d_throttledFailedAckMessages.d_countSinceLastReset -= _numSkipped; if (_numSkipped > d_throttledFailedAckMessages.d_maxCountPerInterval) { _numSkipped -= d_throttledFailedAckMessages.d_maxCountPerInterval; { { for (const BloombergLP::ball::CategoryHolder *ball_log_cAtEgOrYhOlDeR = BloombergLP::ball::Log::categoryHolderIfEnabled<(BloombergLP::ball::Severity::e_INFO)>( ball_log_getCategoryHolder(BALL_LOG_CATEGORYHOLDER)); ball_log_cAtEgOrYhOlDeR; ) for (BloombergLP::ball::Log_Stream ball_log_lOg_StReAm( ball_log_cAtEgOrYhOlDeR->category(), "/Users/emalygin/work/blazingmq/src/groups/bmq/bmqimp/bmqimp_brokersession.cpp", 3751, (BloombergLP::ball::Severity::e_INFO)); ball_log_cAtEgOrYhOlDeR; ball_log_cAtEgOrYhOlDeR = 0) (ball_log_lOg_StReAm.stream()) << "THROTTLED_ACTION - resetting throttling " << "counter '" << "d_throttledFailedAckMessages" << "' (" << _numSkipped << " actions skipped)."; }; } } } } if (++d_throttledFailedAckMessages.d_countSinceLastReset <= d_throttledFailedAckMessages.d_maxCountPerInterval) { for (const BloombergLP::ball::CategoryHolder *ball_log_cAtEgOrYhOlDeR = BloombergLP::ball::Log::categoryHolderIfEnabled<(BloombergLP::ball::Severity::e_ERROR)>( ball_log_getCategoryHolder(BALL_LOG_CATEGORYHOLDER)); ball_log_cAtEgOrYhOlDeR; ) for (BloombergLP::ball::Log_Stream ball_log_lOg_StReAm( ball_log_cAtEgOrYhOlDeR->category(), "/Users/emalygin/work/blazingmq/src/groups/bmq/bmqimp/bmqimp_brokersession.cpp", 3751, (BloombergLP::ball::Severity::e_ERROR)); ball_log_cAtEgOrYhOlDeR; ball_log_cAtEgOrYhOlDeR = 0) (ball_log_lOg_StReAm.stream()) << "Failed ACK for queue '" << queue->uri() << "' [status: " << bmqp::ProtocolUtil::ackResultFromCode(ackMsg.status()) << ", GUID: " << ackMsg.messageGUID() << "]";; } else { } }

Note the double ;; in the expansion

These places can be found by searching the codebase by ;); pattern.
More places:
https://github.com/search?q=repo%3Abloomberg%2Fblazingmq+%22%3B%29%3B%22&type=code

These places confuse cppcheck, so it generates alarms like this:

groups/mqb/mqbblp/mqbblp_localqueue.cpp:422:70: error: There is an unknown macro here somewhere. Configuration is required. If ; is a macro then please configure it. [unknownMacro]
                << "]. Queue not opened in WRITE mode by the client.";);
                                                                     ^

Proposal

Get rid of double semicolon by removing one ;: basically convert these places ;); -> );, so ; is placed only by macro itself.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions