qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: 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 7/7] util/fifo8: Introduce fifo8_discard()
Date: Mon, 22 Jul 2024 18:12:33 +0200	[thread overview]
Message-ID: <18f7d975-617e-4791-b921-7df7c9ef2d1d@linaro.org> (raw)
In-Reply-To: <20240722160745.67904-8-philmd@linaro.org>

On 22/7/24 18:07, Philippe Mathieu-Daudé wrote:
> Add the fifo8_discard() helper for clarity.
> It is a simple wrapper over fifo8_pop_buf().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/qemu/fifo8.h | 8 ++++++++
>   hw/scsi/esp.c        | 2 +-
>   util/fifo8.c         | 6 ++++++
>   3 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
> index 21c7a22937..53bafabd25 100644
> --- a/include/qemu/fifo8.h
> +++ b/include/qemu/fifo8.h
> @@ -129,6 +129,14 @@ const uint8_t *fifo8_pop_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
>    */
>   const uint8_t *fifo8_peek_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
>   
> +/**
> + * fifo8_discard:
> + * @fifo: FIFO to consume bytes
> + *
> + * Discard (consume) bytes from a FIFO.
> + */
> +void fifo8_discard(Fifo8 *fifo, uint32_t len);
> +
>   /**
>    * fifo8_reset:
>    * @fifo: FIFO to reset
> diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
> index cec847b54a..c703fa7351 100644
> --- a/hw/scsi/esp.c
> +++ b/hw/scsi/esp.c
> @@ -351,7 +351,7 @@ static void do_message_phase(ESPState *s)
>       /* Ignore extended messages for now */
>       if (s->cmdfifo_cdb_offset) {
>           int len = MIN(s->cmdfifo_cdb_offset, fifo8_num_used(&s->cmdfifo));
> -        fifo8_pop_buf(&s->cmdfifo, NULL, len);
> +        fifo8_discard(&s->cmdfifo, len);
>           s->cmdfifo_cdb_offset = 0;
>       }
>   }
> diff --git a/util/fifo8.c b/util/fifo8.c
> index 6610b79182..ea39ca2552 100644
> --- a/util/fifo8.c
> +++ b/util/fifo8.c
> @@ -131,6 +131,12 @@ uint32_t fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen)
>       return n1 + n2;
>   }
>   
> +void fifo8_consume(Fifo8 *fifo, uint32_t len)

Sorry, forgot to s/fifo8_consume/fifo8_discard/.

> +{
> +    len -= fifo8_pop_buf(fifo, NULL, len);
> +    assert(len == 0);
> +}
> +
>   bool fifo8_is_empty(Fifo8 *fifo)
>   {
>       return (fifo->num == 0);



  reply	other threads:[~2024-07-22 16:13 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
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é [this message]
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=18f7d975-617e-4791-b921-7df7c9ef2d1d@linaro.org \
    --to=philmd@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=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).