Skip to content

Commit

Permalink
VH-1279: Fix sonar reported bugs in MessageRouterBasic.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Mar 22, 2024
1 parent 62875bb commit f8fd71f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/tmx/TmxCore/src/MessageRouterBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ void MessageRouterBasic::broadcastMessage(MessageReceiver *sender, IvpMessage *m

//PerformanceTimer timer;

pthread_mutex_lock(&this->mMapLock);
pthread_mutex_lock(&this->mActiveBroadcastsLock);
this->mActiveBroadcasts++;
// Volatile type should not be used in compound operations cpp:S6191
auto val = this->mActiveBroadcasts;
this->mActiveBroadcasts = val + 1;
pthread_mutex_unlock(&this->mActiveBroadcastsLock);
pthread_mutex_unlock(&this->mMapLock);

int broadcastCount = 0;

Expand Down Expand Up @@ -107,9 +107,10 @@ void MessageRouterBasic::broadcastMessage(MessageReceiver *sender, IvpMessage *m
}
}
}

// Volatile type should not be used in compound operations cpp:S6191
pthread_mutex_lock(&this->mActiveBroadcastsLock);
this->mActiveBroadcasts--;
auto val = this->mActiveBroadcasts;
this->mActiveBroadcasts = val - 1;
pthread_mutex_unlock(&this->mActiveBroadcastsLock);

//LOG_DEBUG("MessageRouterBasic::broadcastMessage for " << msg->subtype << " from "<< sender->pluginName << " Time (ms) "<<timer_ms);
Expand Down

0 comments on commit f8fd71f

Please sign in to comment.