diff mbox series

[v2,4/7] util/fifo8: Rename fifo8_peek_buf() -> fifo8_peek_constbuf()

Message ID 20240722160745.67904-5-philmd@linaro.org
State New
Headers show
Series util/fifo8: Rework fifo8_pop_buf() | expand

Commit Message

Philippe Mathieu-Daudé July 22, 2024, 4:07 p.m. UTC
Since fifo8_peek_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 ++--
 hw/scsi/esp.c        | 2 +-
 util/fifo8.c         | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

Comments

Pierrick Bouvier July 22, 2024, 9:04 p.m. UTC | #1
On 7/22/24 09:07, Philippe Mathieu-Daudé wrote:
> Since fifo8_peek_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 ++--
>   hw/scsi/esp.c        | 2 +-
>   util/fifo8.c         | 2 +-
>   3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
> index 2692d6bfda..79450f4583 100644
> --- a/include/qemu/fifo8.h
> +++ b/include/qemu/fifo8.h
> @@ -89,7 +89,7 @@ uint8_t fifo8_pop(Fifo8 *fifo);
>   const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
>   
>   /**
> - * fifo8_peek_buf: read upto max bytes from the fifo
> + * fifo8_peek_constbuf: read upto max bytes from the fifo
>    * @fifo: FIFO to read from
>    * @max: maximum number of bytes to peek
>    * @numptr: pointer filled with number of bytes returned (can be NULL)
> @@ -113,7 +113,7 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
>    *
>    * Returns: A pointer to peekable data.
>    */
> -const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
> +const uint8_t *fifo8_peek_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
>   
>   /**
>    * fifo8_reset:
> diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
> index 8504dd30a0..526ed91bef 100644
> --- a/hw/scsi/esp.c
> +++ b/hw/scsi/esp.c
> @@ -486,7 +486,7 @@ static bool esp_cdb_ready(ESPState *s)
>           return false;
>       }
>   
> -    pbuf = fifo8_peek_buf(&s->cmdfifo, len, &n);
> +    pbuf = fifo8_peek_constbuf(&s->cmdfifo, len, &n);
>       if (n < len) {
>           /*
>            * In normal use the cmdfifo should never wrap, but include this check
> diff --git a/util/fifo8.c b/util/fifo8.c
> index 2925fe5611..21943c6032 100644
> --- a/util/fifo8.c
> +++ b/util/fifo8.c
> @@ -92,7 +92,7 @@ static const uint8_t *fifo8_peekpop_buf(Fifo8 *fifo, uint32_t max,
>       return ret;
>   }
>   
> -const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
> +const uint8_t *fifo8_peek_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
>   {
>       return fifo8_peekpop_buf(fifo, max, numptr, false);
>   }

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Mark Cave-Ayland July 22, 2024, 9:22 p.m. UTC | #2
On 22/07/2024 17:07, Philippe Mathieu-Daudé wrote:

> Since fifo8_peek_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.

Perhaps fifo8_peek_bufptr() is a better reflection that it is a pointer to the 
internal buffer that is being returned here?

Still:

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.

> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/qemu/fifo8.h | 4 ++--
>   hw/scsi/esp.c        | 2 +-
>   util/fifo8.c         | 2 +-
>   3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
> index 2692d6bfda..79450f4583 100644
> --- a/include/qemu/fifo8.h
> +++ b/include/qemu/fifo8.h
> @@ -89,7 +89,7 @@ uint8_t fifo8_pop(Fifo8 *fifo);
>   const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
>   
>   /**
> - * fifo8_peek_buf: read upto max bytes from the fifo
> + * fifo8_peek_constbuf: read upto max bytes from the fifo
>    * @fifo: FIFO to read from
>    * @max: maximum number of bytes to peek
>    * @numptr: pointer filled with number of bytes returned (can be NULL)
> @@ -113,7 +113,7 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
>    *
>    * Returns: A pointer to peekable data.
>    */
> -const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
> +const uint8_t *fifo8_peek_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
>   
>   /**
>    * fifo8_reset:
> diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
> index 8504dd30a0..526ed91bef 100644
> --- a/hw/scsi/esp.c
> +++ b/hw/scsi/esp.c
> @@ -486,7 +486,7 @@ static bool esp_cdb_ready(ESPState *s)
>           return false;
>       }
>   
> -    pbuf = fifo8_peek_buf(&s->cmdfifo, len, &n);
> +    pbuf = fifo8_peek_constbuf(&s->cmdfifo, len, &n);
>       if (n < len) {
>           /*
>            * In normal use the cmdfifo should never wrap, but include this check
> diff --git a/util/fifo8.c b/util/fifo8.c
> index 2925fe5611..21943c6032 100644
> --- a/util/fifo8.c
> +++ b/util/fifo8.c
> @@ -92,7 +92,7 @@ static const uint8_t *fifo8_peekpop_buf(Fifo8 *fifo, uint32_t max,
>       return ret;
>   }
>   
> -const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
> +const uint8_t *fifo8_peek_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
>   {
>       return fifo8_peekpop_buf(fifo, max, numptr, false);
>   }
diff mbox series

Patch

diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
index 2692d6bfda..79450f4583 100644
--- a/include/qemu/fifo8.h
+++ b/include/qemu/fifo8.h
@@ -89,7 +89,7 @@  uint8_t fifo8_pop(Fifo8 *fifo);
 const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
 
 /**
- * fifo8_peek_buf: read upto max bytes from the fifo
+ * fifo8_peek_constbuf: read upto max bytes from the fifo
  * @fifo: FIFO to read from
  * @max: maximum number of bytes to peek
  * @numptr: pointer filled with number of bytes returned (can be NULL)
@@ -113,7 +113,7 @@  const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
  *
  * Returns: A pointer to peekable data.
  */
-const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
+const uint8_t *fifo8_peek_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
 
 /**
  * fifo8_reset:
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 8504dd30a0..526ed91bef 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -486,7 +486,7 @@  static bool esp_cdb_ready(ESPState *s)
         return false;
     }
 
-    pbuf = fifo8_peek_buf(&s->cmdfifo, len, &n);
+    pbuf = fifo8_peek_constbuf(&s->cmdfifo, len, &n);
     if (n < len) {
         /*
          * In normal use the cmdfifo should never wrap, but include this check
diff --git a/util/fifo8.c b/util/fifo8.c
index 2925fe5611..21943c6032 100644
--- a/util/fifo8.c
+++ b/util/fifo8.c
@@ -92,7 +92,7 @@  static const uint8_t *fifo8_peekpop_buf(Fifo8 *fifo, uint32_t max,
     return ret;
 }
 
-const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
+const uint8_t *fifo8_peek_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
 {
     return fifo8_peekpop_buf(fifo, max, numptr, false);
 }