Merge branch 'bugfix/esp_ringbuf_static_analyzer_v5.4' into 'release/v5.4'

fix(ringbuf): fixed logic errors when compiling with CONFIG_COMPILER_STATIC_ANALYZER (v5.4)

See merge request espressif/esp-idf!35300
This commit is contained in:
Jiang Jiang Jian
2024-11-30 10:37:00 +08:00

View File

@@ -829,7 +829,7 @@ static BaseType_t prvReceiveGeneric(Ringbuffer_t *pxRingbuffer,
BaseType_t xEntryTimeSet = pdFALSE; BaseType_t xEntryTimeSet = pdFALSE;
TimeOut_t xTimeOut; TimeOut_t xTimeOut;
ESP_STATIC_ANALYZER_CHECK(!pvItem1 || !pvItem2 || !xItemSize1 || !xItemSize2, pdFALSE); ESP_STATIC_ANALYZER_CHECK(!pvItem1 || !xItemSize1, pdFALSE);
while (xExitLoop == pdFALSE) { while (xExitLoop == pdFALSE) {
portENTER_CRITICAL(&pxRingbuffer->mux); portENTER_CRITICAL(&pxRingbuffer->mux);
@@ -845,6 +845,7 @@ static BaseType_t prvReceiveGeneric(Ringbuffer_t *pxRingbuffer,
} }
//If split buffer, check for split items //If split buffer, check for split items
if (pxRingbuffer->uxRingbufferFlags & rbALLOW_SPLIT_FLAG) { if (pxRingbuffer->uxRingbufferFlags & rbALLOW_SPLIT_FLAG) {
ESP_STATIC_ANALYZER_CHECK(!pvItem2 || !xItemSize2, pdFALSE);
if (xIsSplit == pdTRUE) { if (xIsSplit == pdTRUE) {
*pvItem2 = pxRingbuffer->pvGetItem(pxRingbuffer, &xIsSplit, 0, xItemSize2); *pvItem2 = pxRingbuffer->pvGetItem(pxRingbuffer, &xIsSplit, 0, xItemSize2);
configASSERT(*pvItem2 < *pvItem1); //Check wrap around has occurred configASSERT(*pvItem2 < *pvItem1); //Check wrap around has occurred
@@ -890,7 +891,7 @@ static BaseType_t prvReceiveGenericFromISR(Ringbuffer_t *pxRingbuffer,
{ {
BaseType_t xReturn = pdFALSE; BaseType_t xReturn = pdFALSE;
ESP_STATIC_ANALYZER_CHECK(!pvItem1 || !pvItem2 || !xItemSize1 || !xItemSize2, pdFALSE); ESP_STATIC_ANALYZER_CHECK(!pvItem1 || !xItemSize1, pdFALSE);
portENTER_CRITICAL_ISR(&pxRingbuffer->mux); portENTER_CRITICAL_ISR(&pxRingbuffer->mux);
if (prvCheckItemAvail(pxRingbuffer) == pdTRUE) { if (prvCheckItemAvail(pxRingbuffer) == pdTRUE) {
@@ -904,6 +905,7 @@ static BaseType_t prvReceiveGenericFromISR(Ringbuffer_t *pxRingbuffer,
} }
//If split buffer, check for split items //If split buffer, check for split items
if (pxRingbuffer->uxRingbufferFlags & rbALLOW_SPLIT_FLAG) { if (pxRingbuffer->uxRingbufferFlags & rbALLOW_SPLIT_FLAG) {
ESP_STATIC_ANALYZER_CHECK(!pvItem2 || !xItemSize2, pdFALSE);
if (xIsSplit == pdTRUE) { if (xIsSplit == pdTRUE) {
*pvItem2 = pxRingbuffer->pvGetItem(pxRingbuffer, &xIsSplit, 0, xItemSize2); *pvItem2 = pxRingbuffer->pvGetItem(pxRingbuffer, &xIsSplit, 0, xItemSize2);
configASSERT(*pvItem2 < *pvItem1); //Check wrap around has occurred configASSERT(*pvItem2 < *pvItem1); //Check wrap around has occurred