qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>
Subject: [PULL 24/28] util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr()
Date: Tue, 23 Jul 2024 22:38:51 +0200	[thread overview]
Message-ID: <20240723203855.65033-25-philmd@linaro.org> (raw)
In-Reply-To: <20240723203855.65033-1-philmd@linaro.org>

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é <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-Id: <20240722160745.67904-6-philmd@linaro.org>
---
 include/qemu/fifo8.h    | 15 +++++++--------
 chardev/msmouse.c       |  2 +-
 hw/char/goldfish_tty.c  |  2 +-
 hw/net/allwinner_emac.c |  2 +-
 hw/scsi/esp.c           |  4 ++--
 ui/console-vc.c         |  2 +-
 ui/gtk.c                |  2 +-
 util/fifo8.c            |  2 +-
 8 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
index e287e871190..a30220c8e96 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/chardev/msmouse.c b/chardev/msmouse.c
index a774c397b45..2279694cfab 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 cdff46bc13b..c2e1f6537f7 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 989839784a9..d40ff37e994 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 412c8cf2260..7e9657e9c30 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/ui/console-vc.c b/ui/console-vc.c
index 899fa11c948..8393d532e7f 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 bc29f7a1b4f..8e14c2ac81d 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 566b0893441..5bbb6150b60 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);
 }
-- 
2.41.0



  parent reply	other threads:[~2024-07-23 20:42 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 01/28] accel: Restrict probe_access*() functions to TCG Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 02/28] hw/i386/intel_iommu: Extract device IOTLB invalidation logic Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 03/28] hw/intc/loongson_ipi: Access memory in little endian Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 04/28] hw/intc/loongson_ipi: Fix resource leak Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 05/28] hw/intc/loongson_ipi: Declare QOM types using DEFINE_TYPES() macro Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 06/28] docs: Correct Loongarch -> LoongArch Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 07/28] docs/interop/firmware.json: add new enum FirmwareFormat Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 08/28] docs/interop/firmware.json: add new enum FirmwareArchitecture Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 09/28] docs/interop/firmware.json: convert "Example" section Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 10/28] hw/i2c/mpc_i2c: Fix mmio region size Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 11/28] hw/mips/loongson3_virt: remove useless type cast Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 12/28] util/range: Make ranges_overlap() return bool Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 13/28] cxl/mailbox: make range overlap check more readable Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 14/28] sparc/ldst_helper: " Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 15/28] system/memory_mapping: " Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 16/28] crypto/block-luks: " Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 17/28] dump: " Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 18/28] hw/nubus/virtio-mmio: Fix missing ERRP_GUARD() in realize handler Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 19/28] hw/char/goldfish: Use DMA memory API Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 20/28] chardev/char-fe: Document returned value on error Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 21/28] util/fifo8: Fix style Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 22/28] util/fifo8: Use fifo8_reset() in fifo8_create() Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 23/28] util/fifo8: Rename fifo8_peek_buf() -> fifo8_peek_bufptr() Philippe Mathieu-Daudé
2024-07-23 20:38 ` Philippe Mathieu-Daudé [this message]
2024-07-23 20:38 ` [PULL 25/28] util/fifo8: Expose fifo8_pop_buf() Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 26/28] util/fifo8: Introduce fifo8_drop() Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 27/28] MAINTAINERS: Cover guest-agent in QAPI schema Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 28/28] MAINTAINERS: Add myself as a reviewer of machine core Philippe Mathieu-Daudé
2024-07-24  8:14 ` [PULL 00/28] Misc HW+ patches for 2024-07-23 Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240723203855.65033-25-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).