From 241c38b5c0bcd7ef1eb0365949d018af31cac08d Mon Sep 17 00:00:00 2001 From: tgotic Date: Thu, 4 Aug 2022 16:41:18 +0200 Subject: [PATCH] Move xSemaphoreGive out of configASSERT xSemaphoreGive won't be executed in configASSERT and semaphore will stay locked if NDEBUG (idf v5) or CONFIG_FREERTOS_ASSERT_DISABLE (idf v3, v4) are defined. --- components/esp_ringbuf/ringbuf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/esp_ringbuf/ringbuf.c b/components/esp_ringbuf/ringbuf.c index cbd58e3622..d832f9753b 100644 --- a/components/esp_ringbuf/ringbuf.c +++ b/components/esp_ringbuf/ringbuf.c @@ -1358,7 +1358,8 @@ BaseType_t xRingbufferAddToQueueSetRead(RingbufHandle_t xRingbuffer, QueueSetHan xReturn = xQueueAddToSet(rbGET_RX_SEM_HANDLE(pxRingbuffer), xQueueSet); if (xHoldSemaphore == pdTRUE) { //Return semaphore if temporarily held - configASSERT(xSemaphoreGive(rbGET_RX_SEM_HANDLE(pxRingbuffer)) == pdTRUE); + xHoldSemaphore = xSemaphoreGive(rbGET_RX_SEM_HANDLE(pxRingbuffer)); + configASSERT(xHoldSemaphore == pdTRUE); } portEXIT_CRITICAL(&pxRingbuffer->mux); return xReturn; @@ -1384,7 +1385,8 @@ BaseType_t xRingbufferRemoveFromQueueSetRead(RingbufHandle_t xRingbuffer, QueueS xReturn = xQueueRemoveFromSet(rbGET_RX_SEM_HANDLE(pxRingbuffer), xQueueSet); if (xHoldSemaphore == pdTRUE) { //Return semaphore if temporarily held - configASSERT(xSemaphoreGive(rbGET_RX_SEM_HANDLE(pxRingbuffer)) == pdTRUE); + xHoldSemaphore = xSemaphoreGive(rbGET_RX_SEM_HANDLE(pxRingbuffer)); + configASSERT(xHoldSemaphore == pdTRUE); } portEXIT_CRITICAL(&pxRingbuffer->mux); return xReturn;