Message ID | 20240719151628.46253-3-philmd@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | util/fifo8: Introduce fifo8_change_capacity() | expand |
On 19/07/2024 16:16, Philippe Mathieu-Daudé wrote: > Avoid open-coding fifo8_reset() in fifo8_create(). > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > util/fifo8.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/util/fifo8.c b/util/fifo8.c > index 4e01b532d9..2925fe5611 100644 > --- a/util/fifo8.c > +++ b/util/fifo8.c > @@ -16,12 +16,17 @@ > #include "migration/vmstate.h" > #include "qemu/fifo8.h" > > +void fifo8_reset(Fifo8 *fifo) > +{ > + fifo->num = 0; > + fifo->head = 0; > +} > + > void fifo8_create(Fifo8 *fifo, uint32_t capacity) > { > fifo->data = g_new(uint8_t, capacity); > fifo->capacity = capacity; > - fifo->head = 0; > - fifo->num = 0; > + fifo8_reset(fifo); > } > > void fifo8_destroy(Fifo8 *fifo) > @@ -97,12 +102,6 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) > return fifo8_peekpop_buf(fifo, max, numptr, true); > } > > -void fifo8_reset(Fifo8 *fifo) > -{ > - fifo->num = 0; > - fifo->head = 0; > -} > - > bool fifo8_is_empty(Fifo8 *fifo) > { > return (fifo->num == 0); Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> ATB, Mark.
diff --git a/util/fifo8.c b/util/fifo8.c index 4e01b532d9..2925fe5611 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -16,12 +16,17 @@ #include "migration/vmstate.h" #include "qemu/fifo8.h" +void fifo8_reset(Fifo8 *fifo) +{ + fifo->num = 0; + fifo->head = 0; +} + void fifo8_create(Fifo8 *fifo, uint32_t capacity) { fifo->data = g_new(uint8_t, capacity); fifo->capacity = capacity; - fifo->head = 0; - fifo->num = 0; + fifo8_reset(fifo); } void fifo8_destroy(Fifo8 *fifo) @@ -97,12 +102,6 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) return fifo8_peekpop_buf(fifo, max, numptr, true); } -void fifo8_reset(Fifo8 *fifo) -{ - fifo->num = 0; - fifo->head = 0; -} - bool fifo8_is_empty(Fifo8 *fifo) { return (fifo->num == 0);
Avoid open-coding fifo8_reset() in fifo8_create(). Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- util/fifo8.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)