From 06252bf5122f047ed5c14fb75f3167f11b882352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 22 Jul 2024 13:25:01 +0200 Subject: [PATCH] util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since fifo8_pop_buf() return a const buffer (which points directly into the FIFO backing store). Rename it using the 'bufptr' suffix to better reflect that it is a pointer to the internal buffer that is being returned. This will help differentiate with methods *copying* the FIFO data. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Reviewed-by: Mark Cave-Ayland Message-Id: <20240722160745.67904-6-philmd@linaro.org> --- chardev/msmouse.c | 2 +- hw/char/goldfish_tty.c | 2 +- hw/net/allwinner_emac.c | 2 +- hw/scsi/esp.c | 4 ++-- include/qemu/fifo8.h | 15 +++++++-------- ui/console-vc.c | 2 +- ui/gtk.c | 2 +- util/fifo8.c | 2 +- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/chardev/msmouse.c b/chardev/msmouse.c index a774c397b4..2279694cfa 100644 --- a/chardev/msmouse.c +++ b/chardev/msmouse.c @@ -81,7 +81,7 @@ static void msmouse_chr_accept_input(Chardev *chr) const uint8_t *buf; uint32_t size; - buf = fifo8_pop_buf(&mouse->outbuf, MIN(len, avail), &size); + buf = fifo8_pop_bufptr(&mouse->outbuf, MIN(len, avail), &size); qemu_chr_be_write(chr, buf, size); len = qemu_chr_be_can_write(chr); avail -= size; diff --git a/hw/char/goldfish_tty.c b/hw/char/goldfish_tty.c index cdff46bc13..c2e1f6537f 100644 --- a/hw/char/goldfish_tty.c +++ b/hw/char/goldfish_tty.c @@ -109,7 +109,7 @@ static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd) len = s->data_len; ptr = s->data_ptr; while (len && !fifo8_is_empty(&s->rx_fifo)) { - const uint8_t *buf = fifo8_pop_buf(&s->rx_fifo, len, &to_copy); + const uint8_t *buf = fifo8_pop_bufptr(&s->rx_fifo, len, &to_copy); dma_memory_write_relaxed(&address_space_memory, ptr, buf, to_copy); diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c index 989839784a..d40ff37e99 100644 --- a/hw/net/allwinner_emac.c +++ b/hw/net/allwinner_emac.c @@ -349,7 +349,7 @@ static void aw_emac_write(void *opaque, hwaddr offset, uint64_t value, "allwinner_emac: TX length > fifo data length\n"); } if (len > 0) { - data = fifo8_pop_buf(fifo, len, &ret); + data = fifo8_pop_bufptr(fifo, len, &ret); qemu_send_packet(nc, data, ret); aw_emac_tx_reset(s, chan); /* Raise TX interrupt */ diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 412c8cf226..7e9657e9c3 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -208,7 +208,7 @@ static uint32_t esp_fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen) } len = maxlen; - buf = fifo8_pop_buf(fifo, len, &n); + buf = fifo8_pop_bufptr(fifo, len, &n); if (dest) { memcpy(dest, buf, n); } @@ -217,7 +217,7 @@ static uint32_t esp_fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen) len -= n; len = MIN(len, fifo8_num_used(fifo)); if (len) { - buf = fifo8_pop_buf(fifo, len, &n2); + buf = fifo8_pop_bufptr(fifo, len, &n2); if (dest) { memcpy(&dest[n], buf, n2); } diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index e287e87119..a30220c8e9 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -63,15 +63,15 @@ void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num); uint8_t fifo8_pop(Fifo8 *fifo); /** - * fifo8_pop_buf: + * fifo8_pop_bufptr: * @fifo: FIFO to pop from * @max: maximum number of bytes to pop * @numptr: pointer filled with number of bytes returned (can be NULL) * * Pop a number of elements from the FIFO up to a maximum of @max. The buffer * containing the popped data is returned. This buffer points directly into - * the FIFO backing store and data is invalidated once any of the fifo8_* APIs - * are called on the FIFO. + * the internal FIFO backing store and data (without checking for overflow!) + * and is invalidated once any of the fifo8_* APIs are called on the FIFO. * * The function may return fewer bytes than requested when the data wraps * around in the ring buffer; in this case only a contiguous part of the data @@ -86,7 +86,7 @@ uint8_t fifo8_pop(Fifo8 *fifo); * * Returns: A pointer to popped data. */ -const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); +const uint8_t *fifo8_pop_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr); /** * fifo8_peek_bufptr: read upto max bytes from the fifo @@ -96,10 +96,9 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); * * Peek into a number of elements from the FIFO up to a maximum of @max. * The buffer containing the data peeked into is returned. This buffer points - * directly into the internal FIFO backing store (without checking for - * overflow!). Since data is invalidated once any of the fifo8_* APIs are - * called on the FIFO, it is the caller responsibility to access it before - * doing further API calls. + * directly into the FIFO backing store. Since data is invalidated once any + * of the fifo8_* APIs are called on the FIFO, it is the caller responsibility + * to access it before doing further API calls. * * The function may return fewer bytes than requested when the data wraps * around in the ring buffer; in this case only a contiguous part of the data diff --git a/ui/console-vc.c b/ui/console-vc.c index 899fa11c94..8393d532e7 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -287,7 +287,7 @@ static void kbd_send_chars(QemuTextConsole *s) const uint8_t *buf; uint32_t size; - buf = fifo8_pop_buf(&s->out_fifo, MIN(len, avail), &size); + buf = fifo8_pop_bufptr(&s->out_fifo, MIN(len, avail), &size); qemu_chr_be_write(s->chr, buf, size); len = qemu_chr_be_can_write(s->chr); avail -= size; diff --git a/ui/gtk.c b/ui/gtk.c index bc29f7a1b4..8e14c2ac81 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1820,7 +1820,7 @@ static void gd_vc_send_chars(VirtualConsole *vc) const uint8_t *buf; uint32_t size; - buf = fifo8_pop_buf(&vc->vte.out_fifo, MIN(len, avail), &size); + buf = fifo8_pop_bufptr(&vc->vte.out_fifo, MIN(len, avail), &size); qemu_chr_be_write(vc->vte.chr, buf, size); len = qemu_chr_be_can_write(vc->vte.chr); avail -= size; diff --git a/util/fifo8.c b/util/fifo8.c index 566b089344..5bbb6150b6 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -97,7 +97,7 @@ const uint8_t *fifo8_peek_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr) return fifo8_peekpop_buf(fifo, max, numptr, false); } -const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) +const uint8_t *fifo8_pop_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr) { return fifo8_peekpop_buf(fifo, max, numptr, true); }