mirror of
https://github.com/esphome/esphome.git
synced 2026-09-13 16:18:41 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user