Fix scoping: declare count outside portENTER_CRITICAL block

BK72xx portENTER_CRITICAL expands to something that introduces a
scope, so variables declared between ENTER/EXIT are not visible after.
This commit is contained in:
J. Nick Koston
2026-03-31 21:43:21 -10:00
parent b980978f05
commit 6e9ebf6b1b
+3 -1
View File
@@ -61,8 +61,10 @@ template<class T, uint8_t SIZE> class FreeRTOSQueue {
// Drops are rare so almost always returns 0 without entering a critical section.
if (this->dropped_count_ == 0)
return 0;
// Declare outside critical section — BK72xx portENTER_CRITICAL may introduce a scope
uint16_t count;
portENTER_CRITICAL();
uint16_t count = this->dropped_count_;
count = this->dropped_count_;
this->dropped_count_ = 0;
portEXIT_CRITICAL();
return count;