mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
sdio_slave: fix strict aliasing violation for sdio_ringbuf_recv()
This happened because of passing sdio_slave_hal_send_desc_t** to function sdio_ringbuf_recv() which is declared to have char** as input parameter
This commit is contained in:
parent
4005886b8a
commit
7db42d3a40
@ -40,7 +40,7 @@ typedef enum {
|
|||||||
} sdio_ringbuf_pointer_t;
|
} sdio_ringbuf_pointer_t;
|
||||||
|
|
||||||
static esp_err_t sdio_ringbuf_send(sdio_ringbuf_t *buf, esp_err_t (*copy_callback)(uint8_t *, void *), void *arg);
|
static esp_err_t sdio_ringbuf_send(sdio_ringbuf_t *buf, esp_err_t (*copy_callback)(uint8_t *, void *), void *arg);
|
||||||
static inline esp_err_t sdio_ringbuf_recv(sdio_ringbuf_t *buf, uint8_t **start, uint8_t **end, ringbuf_get_all_t get_all);
|
static inline esp_err_t sdio_ringbuf_recv(sdio_ringbuf_t *buf, sdio_slave_hal_send_desc_t **start, sdio_slave_hal_send_desc_t **end, ringbuf_get_all_t get_all);
|
||||||
static inline int sdio_ringbuf_return(sdio_ringbuf_t* buf, uint8_t *ptr);
|
static inline int sdio_ringbuf_return(sdio_ringbuf_t* buf, uint8_t *ptr);
|
||||||
|
|
||||||
#define _SEND_DESC_NEXT(x) STAILQ_NEXT(&((sdio_slave_hal_send_desc_t*)x)->dma_desc, qe)
|
#define _SEND_DESC_NEXT(x) STAILQ_NEXT(&((sdio_slave_hal_send_desc_t*)x)->dma_desc, qe)
|
||||||
@ -95,7 +95,7 @@ static esp_err_t sdio_ringbuf_send(sdio_ringbuf_t *buf, esp_err_t (*copy_callbac
|
|||||||
|
|
||||||
// this ringbuf is a return-before-recv-again strategy
|
// this ringbuf is a return-before-recv-again strategy
|
||||||
// since this is designed to be called in the ISR, no parallel logic
|
// since this is designed to be called in the ISR, no parallel logic
|
||||||
static inline esp_err_t sdio_ringbuf_recv(sdio_ringbuf_t *buf, uint8_t **start, uint8_t **end, ringbuf_get_all_t get_all)
|
static inline esp_err_t sdio_ringbuf_recv(sdio_ringbuf_t *buf, sdio_slave_hal_send_desc_t **start, sdio_slave_hal_send_desc_t **end, ringbuf_get_all_t get_all)
|
||||||
{
|
{
|
||||||
HAL_ASSERT(buf->free_ptr == buf->read_ptr); //must return before recv again
|
HAL_ASSERT(buf->free_ptr == buf->read_ptr); //must return before recv again
|
||||||
if (start == NULL && end == NULL) return ESP_ERR_INVALID_ARG; // must have a output
|
if (start == NULL && end == NULL) return ESP_ERR_INVALID_ARG; // must have a output
|
||||||
@ -110,10 +110,10 @@ static inline esp_err_t sdio_ringbuf_recv(sdio_ringbuf_t *buf, uint8_t **start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (start != NULL) {
|
if (start != NULL) {
|
||||||
*start = get_start;
|
*start = (sdio_slave_hal_send_desc_t *) get_start;
|
||||||
}
|
}
|
||||||
if (end != NULL) {
|
if (end != NULL) {
|
||||||
*end = buf->read_ptr;
|
*end = (sdio_slave_hal_send_desc_t *) buf->read_ptr;
|
||||||
}
|
}
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ static esp_err_t init_send_queue(sdio_slave_context_t *hal)
|
|||||||
|
|
||||||
//loop in the ringbuf to link all the desc one after another as a ring
|
//loop in the ringbuf to link all the desc one after another as a ring
|
||||||
for (int i = 0; i < hal->send_queue_size + 1; i++) {
|
for (int i = 0; i < hal->send_queue_size + 1; i++) {
|
||||||
rcv_res = sdio_ringbuf_recv(buf, (uint8_t **) &last, NULL, RINGBUF_GET_ONE);
|
rcv_res = sdio_ringbuf_recv(buf, &last, NULL, RINGBUF_GET_ONE);
|
||||||
assert (rcv_res == ESP_OK);
|
assert (rcv_res == ESP_OK);
|
||||||
|
|
||||||
ret = sdio_ringbuf_send(buf, link_desc_to_last, last);
|
ret = sdio_ringbuf_send(buf, link_desc_to_last, last);
|
||||||
@ -200,7 +200,7 @@ static esp_err_t init_send_queue(sdio_slave_context_t *hal)
|
|||||||
first = NULL;
|
first = NULL;
|
||||||
last = NULL;
|
last = NULL;
|
||||||
//clear the queue
|
//clear the queue
|
||||||
rcv_res = sdio_ringbuf_recv(buf, (uint8_t **) &first, (uint8_t **) &last, RINGBUF_GET_ALL);
|
rcv_res = sdio_ringbuf_recv(buf, &first, &last, RINGBUF_GET_ALL);
|
||||||
assert (rcv_res == ESP_OK);
|
assert (rcv_res == ESP_OK);
|
||||||
HAL_ASSERT(first == last); //there should be only one desc remain
|
HAL_ASSERT(first == last); //there should be only one desc remain
|
||||||
sdio_ringbuf_return(buf, (uint8_t *) first);
|
sdio_ringbuf_return(buf, (uint8_t *) first);
|
||||||
@ -331,9 +331,9 @@ static esp_err_t send_check_new_packet(sdio_slave_context_t *hal)
|
|||||||
sdio_slave_hal_send_desc_t *start = NULL;
|
sdio_slave_hal_send_desc_t *start = NULL;
|
||||||
sdio_slave_hal_send_desc_t *end = NULL;
|
sdio_slave_hal_send_desc_t *end = NULL;
|
||||||
if (hal->sending_mode == SDIO_SLAVE_SEND_PACKET) {
|
if (hal->sending_mode == SDIO_SLAVE_SEND_PACKET) {
|
||||||
ret = sdio_ringbuf_recv(&(hal->send_desc_queue), (uint8_t **) &start, (uint8_t **) &end, RINGBUF_GET_ONE);
|
ret = sdio_ringbuf_recv(&(hal->send_desc_queue), &start, &end, RINGBUF_GET_ONE);
|
||||||
} else { //stream mode
|
} else { //stream mode
|
||||||
ret = sdio_ringbuf_recv(&(hal->send_desc_queue), (uint8_t **) &start, (uint8_t **) &end, RINGBUF_GET_ALL);
|
ret = sdio_ringbuf_recv(&(hal->send_desc_queue), &start, &end, RINGBUF_GET_ALL);
|
||||||
}
|
}
|
||||||
if (ret == ESP_OK) {
|
if (ret == ESP_OK) {
|
||||||
hal->in_flight_head = start;
|
hal->in_flight_head = start;
|
||||||
@ -424,7 +424,7 @@ static esp_err_t send_get_unsent_desc(sdio_slave_context_t *hal, void **out_arg,
|
|||||||
esp_err_t ret;
|
esp_err_t ret;
|
||||||
sdio_slave_hal_send_desc_t *head = NULL;
|
sdio_slave_hal_send_desc_t *head = NULL;
|
||||||
sdio_slave_hal_send_desc_t *tail = NULL;
|
sdio_slave_hal_send_desc_t *tail = NULL;
|
||||||
ret = sdio_ringbuf_recv(&(hal->send_desc_queue), (uint8_t **) &head, (uint8_t **) &tail, RINGBUF_GET_ONE);
|
ret = sdio_ringbuf_recv(&(hal->send_desc_queue), &head, &tail, RINGBUF_GET_ONE);
|
||||||
|
|
||||||
if (ret == ESP_OK) {
|
if (ret == ESP_OK) {
|
||||||
//currently each packet takes only one desc.
|
//currently each packet takes only one desc.
|
||||||
|
Loading…
Reference in New Issue
Block a user