mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-18 06:35:35 +03:00
fix(ble_log): improve robustness with atomics, macro hygiene, and IRAM
- Use __atomic_fetch_add for stat_mgr counters to prevent lost updates under concurrent ISR/task access (H1) - Use __atomic_load_n with ACQUIRE ordering for ref_count spin-loops (L1) - Remove unnecessary BLE_LOG_IRAM_ATTR from ble_log_rt_task since it calls flash-resident functions and cannot run during flash ops (L3) - Add parentheses to BLE_LOG_TRANS_FREE_SPACE and BLE_LOG_MAKE_FRAME_META macro parameters to prevent operator precedence bugs (M6)
This commit is contained in:
@@ -35,7 +35,7 @@ typedef struct {
|
||||
#define BLE_LOG_FRAME_HEAD_LEN (sizeof(ble_log_frame_head_t))
|
||||
#define BLE_LOG_FRAME_TAIL_LEN (sizeof(uint32_t))
|
||||
#define BLE_LOG_FRAME_OVERHEAD (BLE_LOG_FRAME_HEAD_LEN + BLE_LOG_FRAME_TAIL_LEN)
|
||||
#define BLE_LOG_MAKE_FRAME_META(src_code, sn) ((src_code & 0xFF) | (sn << 8))
|
||||
#define BLE_LOG_MAKE_FRAME_META(src_code, sn) (((src_code) & 0xFF) | ((sn) << 8))
|
||||
|
||||
/* ---------------------------------- */
|
||||
/* Log Buffer Manager Defines */
|
||||
|
||||
@@ -27,7 +27,7 @@ typedef struct {
|
||||
void *owner;
|
||||
} ble_log_prph_trans_t;
|
||||
|
||||
#define BLE_LOG_TRANS_FREE_SPACE(trans) (trans->size - trans->pos)
|
||||
#define BLE_LOG_TRANS_FREE_SPACE(trans) ((trans)->size - (trans)->pos)
|
||||
#define BLE_LOG_TRANS_BUF_CNT (4)
|
||||
|
||||
/* INTERFACE */
|
||||
|
||||
Reference in New Issue
Block a user