aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2024-08-28 13:22:51 +0100
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2024-09-13 20:11:13 +0200
commit0b73afec0e0f9230ba6f16a2d667dc214680b4f0 (patch)
tree30ae78cddc166fc5d30473bc0be2445429b72b4c /util
parentf9309d965a70c12244c84d034420c036d18691ce (diff)
fifo8: introduce head variable for fifo8_peekpop_bufptr()
Rather than operate on fifo->head directly, introduce a new head variable which is set to the value of fifo->head and use it instead. This is to allow future adjustment of the head position within the internal FIFO buffer. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Octavian Purdila <tavip@google.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20240828122258.928947-3-mark.cave-ayland@ilande.co.uk> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'util')
-rw-r--r--util/fifo8.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/util/fifo8.c b/util/fifo8.c
index 61bce9d9a0..5faa814a6e 100644
--- a/util/fifo8.c
+++ b/util/fifo8.c
@@ -75,11 +75,12 @@ static const uint8_t *fifo8_peekpop_bufptr(Fifo8 *fifo, uint32_t max,
uint32_t *numptr, bool do_pop)
{
uint8_t *ret;
- uint32_t num;
+ uint32_t num, head;
assert(max > 0 && max <= fifo->num);
- num = MIN(fifo->capacity - fifo->head, max);
- ret = &fifo->data[fifo->head];
+ head = fifo->head;
+ num = MIN(fifo->capacity - head, max);
+ ret = &fifo->data[head];
if (do_pop) {
fifo->head += num;