Skip to content

Commit ce4b678

Browse files
authored
Fix some issues from coverity in ActorSystem (#12831)
1 parent c9f3084 commit ce4b678

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

ydb/library/actors/core/executor_pool_basic.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ namespace NActors {
216216
Harmonizer->Harmonize(hpnow);
217217
}
218218

219-
TAtomic x = AtomicGet(Semaphore);
220-
TSemaphore semaphore = TSemaphore::GetSemaphore(x);
219+
TAtomic semaphoreRaw = AtomicGet(Semaphore);
220+
TSemaphore semaphore = TSemaphore::GetSemaphore(semaphoreRaw);
221221
while (!StopFlag.load(std::memory_order_acquire)) {
222222
if (!semaphore.OldSemaphore || workerId >= 0 && semaphore.CurrentSleepThreadCount < 0) {
223223
if (workerId < 0 || !wctx.IsNeededToWaitNextActivation) {
@@ -234,7 +234,7 @@ namespace NActors {
234234
}
235235
} else {
236236
TInternalActorTypeGuard<EInternalActorSystemActivity::ACTOR_SYSTEM_GET_ACTIVATION_FROM_QUEUE, false> activityGuard;
237-
if (const ui32 activation = std::visit([&revolvingCounter](auto &x) {return x.Pop(++revolvingCounter);}, Activations)) {
237+
if (const ui32 activation = std::visit([&revolvingCounter](auto &queue) {return queue.Pop(++revolvingCounter);}, Activations)) {
238238
if (workerId >= 0) {
239239
Threads[workerId].SetWork();
240240
} else {
@@ -247,8 +247,8 @@ namespace NActors {
247247
}
248248

249249
SpinLockPause();
250-
x = AtomicGet(Semaphore);
251-
semaphore = TSemaphore::GetSemaphore(x);
250+
semaphoreRaw = AtomicGet(Semaphore);
251+
semaphore = TSemaphore::GetSemaphore(semaphoreRaw);
252252
}
253253

254254
return nullptr;

ydb/library/actors/core/executor_pool_io.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ namespace NActors {
3434
i16 workerId = wctx.WorkerId;
3535
Y_DEBUG_ABORT_UNLESS(workerId < PoolThreads);
3636

37-
const TAtomic x = AtomicDecrement(Semaphore);
38-
if (x < 0) {
37+
const TAtomic semaphoreRaw = AtomicDecrement(Semaphore);
38+
if (semaphoreRaw < 0) {
3939
TExecutorThreadCtx& threadCtx = Threads[workerId];
4040
ThreadQueue.Push(workerId + 1, revolvingCounter);
4141

@@ -54,7 +54,7 @@ namespace NActors {
5454
}
5555

5656
while (!StopFlag.load(std::memory_order_acquire)) {
57-
if (const ui32 activation = std::visit([&revolvingCounter](auto &x){return x.Pop(++revolvingCounter);}, Activations)) {
57+
if (const ui32 activation = std::visit([&revolvingCounter](auto &queue){return queue.Pop(++revolvingCounter);}, Activations)) {
5858
return MailboxTable->Get(activation);
5959
}
6060
SpinLockPause();
@@ -87,14 +87,14 @@ namespace NActors {
8787
}
8888

8989
void TIOExecutorPool::ScheduleActivationEx(TMailbox* mailbox, ui64 revolvingWriteCounter) {
90-
std::visit([mailbox, revolvingWriteCounter](auto &x) {
91-
x.Push(mailbox->Hint, revolvingWriteCounter);
90+
std::visit([mailbox, revolvingWriteCounter](auto &queue) {
91+
queue.Push(mailbox->Hint, revolvingWriteCounter);
9292
}, Activations);
93-
const TAtomic x = AtomicIncrement(Semaphore);
94-
if (x <= 0) {
93+
const TAtomic semaphoreRaw = AtomicIncrement(Semaphore);
94+
if (semaphoreRaw <= 0) {
9595
for (;; ++revolvingWriteCounter) {
96-
if (const ui32 x = ThreadQueue.Pop(revolvingWriteCounter)) {
97-
const ui32 threadIdx = x - 1;
96+
if (const ui32 threadId = ThreadQueue.Pop(revolvingWriteCounter)) {
97+
const ui32 threadIdx = threadId - 1;
9898
Threads[threadIdx].WaitingPad.Unpark();
9999
return;
100100
}

ydb/library/actors/core/harmonizer/cpu_consumption.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace {
3838
poolConsumption->LastSecondCpu += threadLastSecondCpu;
3939
LWPROBE_WITH_DEBUG(HarmonizeCheckPoolByThread, pool.Pool->PoolId, pool.Pool->GetName(), threadIdx, threadElapsed, threadCpu, threadLastSecondElapsed, threadLastSecondCpu);
4040
}
41-
for (ui32 sharedIdx = 0; sharedIdx < pool.SharedInfo.size(); ++sharedIdx) {
41+
for (i16 sharedIdx = 0; sharedIdx < static_cast<i16>(pool.SharedInfo.size()); ++sharedIdx) {
4242
float sharedElapsed = Rescale(pool.GetSharedElapsed(sharedIdx));
4343
float sharedLastSecondElapsed = Rescale(pool.GetLastSecondSharedElapsed(sharedIdx));
4444
float sharedCpu = Rescale(pool.GetSharedCpu(sharedIdx));

0 commit comments

Comments
 (0)