mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 11:17:20 +02:00
fix(ringbuf): fixed logic errors when compiling with __clang_analyzer__
We return pdFALSE if prvReceiveGeneric was called with any of the input pointers as NULL, but pvItem2 and xItemSize2 will only be non-null for split buffers. Closes https://github.com/espressif/esp-idf/issues/14905
This commit is contained in:
@ -831,7 +831,7 @@ static BaseType_t prvReceiveGeneric(Ringbuffer_t *pxRingbuffer,
|
|||||||
|
|
||||||
#ifdef __clang_analyzer__
|
#ifdef __clang_analyzer__
|
||||||
// Teach clang-tidy that if NULL pointers are provided, this function will never dereference them
|
// Teach clang-tidy that if NULL pointers are provided, this function will never dereference them
|
||||||
if (!pvItem1 || !pvItem2 || !xItemSize1 || !xItemSize2) {
|
if (!pvItem1 || !xItemSize1) {
|
||||||
return pdFALSE;
|
return pdFALSE;
|
||||||
}
|
}
|
||||||
#endif /*__clang_analyzer__ */
|
#endif /*__clang_analyzer__ */
|
||||||
@ -850,6 +850,12 @@ 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) {
|
||||||
|
#ifdef __clang_analyzer__
|
||||||
|
// Teach clang-tidy that if NULL pointers are provided, this function will never dereference them
|
||||||
|
if (!pvItem2 || !xItemSize2) {
|
||||||
|
return pdFALSE;
|
||||||
|
}
|
||||||
|
#endif /*__clang_analyzer__ */
|
||||||
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
|
||||||
@ -897,7 +903,7 @@ static BaseType_t prvReceiveGenericFromISR(Ringbuffer_t *pxRingbuffer,
|
|||||||
|
|
||||||
#ifdef __clang_analyzer__
|
#ifdef __clang_analyzer__
|
||||||
// Teach clang-tidy that if NULL pointers are provided, this function will never dereference them
|
// Teach clang-tidy that if NULL pointers are provided, this function will never dereference them
|
||||||
if (!pvItem1 || !pvItem2 || !xItemSize1 || !xItemSize2) {
|
if (!pvItem1 || !xItemSize1) {
|
||||||
return pdFALSE;
|
return pdFALSE;
|
||||||
}
|
}
|
||||||
#endif /*__clang_analyzer__ */
|
#endif /*__clang_analyzer__ */
|
||||||
@ -914,6 +920,12 @@ 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) {
|
||||||
|
#ifdef __clang_analyzer__
|
||||||
|
// Teach clang-tidy that if NULL pointers are provided, this function will never dereference them
|
||||||
|
if (!pvItem2 || !xItemSize2) {
|
||||||
|
return pdFALSE;
|
||||||
|
}
|
||||||
|
#endif /*__clang_analyzer__ */
|
||||||
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
|
||||||
|
Reference in New Issue
Block a user