From: Beniamino Galvani Date: Thu, 30 Jan 2014 22:02:05 +0000 (+0100) Subject: util/fifo8: clear fifo head upon reset X-Git-Tag: qemu-xen-4.5.0-rc1~220^2~3 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=58892d4782bf516e8356e3adfe4fc9b10c397b2f;p=qemu-upstream-4.6-testing.git util/fifo8: clear fifo head upon reset To improve the predictability of fifo8_pop_buf(), the fifo head is set to the start of data buffer upon a reset so that the first call to the function will be able to retrieve all data in the fifo. Signed-off-by: Beniamino Galvani Reviewed-by: Peter Crosthwaite Signed-off-by: Peter Maydell --- diff --git a/util/fifo8.c b/util/fifo8.c index a7503c229..6a43482c9 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -89,6 +89,7 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *num) void fifo8_reset(Fifo8 *fifo) { fifo->num = 0; + fifo->head = 0; } bool fifo8_is_empty(Fifo8 *fifo)