qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: "Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org
Subject: Re: [PATCH v2 5/7] util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_constbuf()
Date: Mon, 22 Jul 2024 14:05:23 -0700	[thread overview]
Message-ID: <758b3aa3-8f82-4fc2-a705-3f7896ebd83a@linaro.org> (raw)
In-Reply-To: <20240722160745.67904-6-philmd@linaro.org>

On 7/22/24 09:07, Philippe Mathieu-Daudé wrote:
> Since fifo8_pop_buf() return a const buffer (which points
> directly into the FIFO backing store), rename it using the
> 'constbuf' suffix. This will help differentiate with methods
> *copying* the FIFO data.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/qemu/fifo8.h    | 4 ++--
>   chardev/msmouse.c       | 2 +-
>   hw/char/goldfish_tty.c  | 4 ++--
>   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, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
> index 79450f4583..686918a3a4 100644
> --- a/include/qemu/fifo8.h
> +++ b/include/qemu/fifo8.h
> @@ -63,7 +63,7 @@ void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num);
>   uint8_t fifo8_pop(Fifo8 *fifo);
>   
>   /**
> - * fifo8_pop_buf:
> + * fifo8_pop_constbuf:
>    * @fifo: FIFO to pop from
>    * @max: maximum number of bytes to pop
>    * @numptr: pointer filled with number of bytes returned (can be NULL)
> @@ -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_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
>   
>   /**
>    * fifo8_peek_constbuf: read upto max bytes from the fifo
> diff --git a/chardev/msmouse.c b/chardev/msmouse.c
> index a774c397b4..08836d92e8 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_constbuf(&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 f8ff043c39..2c5004851d 100644
> --- a/hw/char/goldfish_tty.c
> +++ b/hw/char/goldfish_tty.c
> @@ -69,7 +69,7 @@ static uint64_t goldfish_tty_read(void *opaque, hwaddr addr,
>   static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd)
>   {
>       uint32_t to_copy;
> -    uint8_t *buf;
> +    const uint8_t *buf;
>       uint8_t data_out[GOLFISH_TTY_BUFFER_SIZE];
>       int len;
>       uint64_t ptr;
> @@ -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)) {
> -            buf = (uint8_t *)fifo8_pop_buf(&s->rx_fifo, len, &to_copy);
> +            buf = fifo8_pop_constbuf(&s->rx_fifo, len, &to_copy);
>               address_space_rw(&address_space_memory, ptr,
>                               MEMTXATTRS_UNSPECIFIED, buf, to_copy, 1);
>   
> diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c
> index 989839784a..3b0a2ee07e 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_constbuf(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 526ed91bef..64384f9b0e 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_constbuf(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_constbuf(fifo, len, &n2);
>           if (dest) {
>               memcpy(&dest[n], buf, n2);
>           }
> diff --git a/ui/console-vc.c b/ui/console-vc.c
> index 899fa11c94..e9906aae59 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_constbuf(&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..a4db90e8cb 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_constbuf(&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 21943c6032..31f0d34c0c 100644
> --- a/util/fifo8.c
> +++ b/util/fifo8.c
> @@ -97,7 +97,7 @@ const uint8_t *fifo8_peek_constbuf(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_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
>   {
>       return fifo8_peekpop_buf(fifo, max, numptr, true);
>   }

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>

  reply	other threads:[~2024-07-22 21:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-22 16:07 [PATCH v2 0/7] util/fifo8: Rework fifo8_pop_buf() Philippe Mathieu-Daudé
2024-07-22 16:07 ` [PATCH v2 1/7] chardev/char-fe: Document returned value on error Philippe Mathieu-Daudé
2024-07-22 21:06   ` Pierrick Bouvier
2024-07-22 16:07 ` [PATCH v2 2/7] util/fifo8: Fix style Philippe Mathieu-Daudé
2024-07-22 21:04   ` Pierrick Bouvier
2024-07-22 21:17   ` Mark Cave-Ayland
2024-07-22 16:07 ` [PATCH v2 3/7] util/fifo8: Use fifo8_reset() in fifo8_create() Philippe Mathieu-Daudé
2024-07-22 21:06   ` Pierrick Bouvier
2024-07-22 16:07 ` [PATCH v2 4/7] util/fifo8: Rename fifo8_peek_buf() -> fifo8_peek_constbuf() Philippe Mathieu-Daudé
2024-07-22 21:04   ` Pierrick Bouvier
2024-07-22 21:22   ` Mark Cave-Ayland
2024-07-22 16:07 ` [PATCH v2 5/7] util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_constbuf() Philippe Mathieu-Daudé
2024-07-22 21:05   ` Pierrick Bouvier [this message]
2024-07-22 21:24   ` Mark Cave-Ayland
2024-07-22 16:07 ` [PATCH v2 6/7] util/fifo8: Expose fifo8_pop_buf() Philippe Mathieu-Daudé
2024-07-22 21:06   ` Pierrick Bouvier
2024-07-22 21:26   ` Mark Cave-Ayland
2024-07-22 21:39     ` Philippe Mathieu-Daudé
2024-07-22 22:23       ` Mark Cave-Ayland
2024-07-22 16:07 ` [PATCH v2 7/7] util/fifo8: Introduce fifo8_discard() Philippe Mathieu-Daudé
2024-07-22 16:12   ` Philippe Mathieu-Daudé
2024-07-22 21:07     ` Pierrick Bouvier
2024-07-22 21:52   ` Mark Cave-Ayland
2024-07-23 18:02 ` [PATCH v2 0/7] util/fifo8: Rework fifo8_pop_buf() Philippe Mathieu-Daudé

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=758b3aa3-8f82-4fc2-a705-3f7896ebd83a@linaro.org \
    --to=pierrick.bouvier@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.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).