Modify the null pointer fifo to access first and then judge

This commit is contained in:
Eric_He
2023-04-23 10:55:42 +08:00
committed by GitHub
parent 0cef33e152
commit 1961644fa4

View File

@@ -98,11 +98,11 @@ unsigned int salof_fifo_read(salof_fifo_t fifo, void *buff, unsigned int len, un
{
int l;
salof_sem_pend(fifo->sem, timeout);
if((!fifo) || (!buff) || (!len))
return 0;
salof_sem_pend(fifo->sem, timeout);
len = FIFO_MIN(len, fifo->in - fifo->out);
l = FIFO_MIN(len, (fifo->size - (fifo->out & (fifo->size -1))));