kopia lustrzana https://github.com/espressif/esp-idf
Fix an assert that erroneously triggered when popping a zero-byte payload from the end of the ringbuffer
rodzic
3161854efb
commit
d0bf9e61da
|
@ -337,7 +337,7 @@ static void returnItemToRingbufDefault(ringbuf_t *rb, void *item) {
|
||||||
uint8_t *data=(uint8_t*)item;
|
uint8_t *data=(uint8_t*)item;
|
||||||
configASSERT(((int)rb->free_ptr&3)==0);
|
configASSERT(((int)rb->free_ptr&3)==0);
|
||||||
configASSERT(data >= rb->data);
|
configASSERT(data >= rb->data);
|
||||||
configASSERT(data < rb->data+rb->size);
|
configASSERT(data <= rb->data+rb->size);
|
||||||
//Grab the buffer entry that preceeds the buffer
|
//Grab the buffer entry that preceeds the buffer
|
||||||
buf_entry_hdr_t *hdr=(buf_entry_hdr_t*)(data-sizeof(buf_entry_hdr_t));
|
buf_entry_hdr_t *hdr=(buf_entry_hdr_t*)(data-sizeof(buf_entry_hdr_t));
|
||||||
configASSERT(hdr->len < rb->size);
|
configASSERT(hdr->len < rb->size);
|
||||||
|
|
|
@ -195,3 +195,26 @@ TEST_CASE("FreeRTOS ringbuffer test, w/ splitting items", "[freertos][ignore]")
|
||||||
testRingbuffer(1);
|
testRingbuffer(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST_CASE("FreeRTOS ringbuffer test, check if zero-length items are handled correctly", "[freertos]")
|
||||||
|
{
|
||||||
|
rb = xRingbufferCreate(32, 0);
|
||||||
|
int r;
|
||||||
|
void *v;
|
||||||
|
size_t sz;
|
||||||
|
for (int x=0; x<128; x++) {
|
||||||
|
if (x!=127) {
|
||||||
|
//Send an item
|
||||||
|
r = xRingbufferSend(rb, NULL, 0, 10000 / portTICK_PERIOD_MS);
|
||||||
|
assert(r==pdTRUE);
|
||||||
|
}
|
||||||
|
if (x!=0) {
|
||||||
|
//Receive an item
|
||||||
|
v=xRingbufferReceive(rb, &sz, 10000 / portTICK_PERIOD_MS);
|
||||||
|
assert(sz==0);
|
||||||
|
vRingbufferReturnItem(rb, v); //actually not needed for NULL data...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vRingbufferDelete(rb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue