diff mbox series

[2/2] 9pfs: simplify blksize_to_iounit()

Message ID b84eb324d2ebdcc6f9c442c97b5b4d01eecb4f43.1632758315.git.qemu_oss@crudebyte.com
State New
Headers show
Series 9pfs: iounit cleanup | expand

Commit Message

Christian Schoenebeck Sept. 27, 2021, 3:50 p.m. UTC
Use QEMU_ALIGN_DOWN() macro to reduce code and to make it
more human readable.

Suggested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
 hw/9pfs/9p.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Greg Kurz Sept. 27, 2021, 4:28 p.m. UTC | #1
On Mon, 27 Sep 2021 17:50:36 +0200
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:

> Use QEMU_ALIGN_DOWN() macro to reduce code and to make it
> more human readable.
> 
> Suggested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  hw/9pfs/9p.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index c65584173a..29cc19c90a 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -1280,8 +1280,7 @@ static int32_t blksize_to_iounit(const V9fsPDU *pdu, int32_t blksize)
>       * as well as less than (client msize - P9_IOHDRSZ)
>       */
>      if (blksize) {
> -        iounit = blksize;
> -        iounit *= (s->msize - P9_IOHDRSZ) / blksize;
> +        iounit = QEMU_ALIGN_DOWN(s->msize - P9_IOHDRSZ, blksize);
>      }
>      if (!iounit) {
>          iounit = s->msize - P9_IOHDRSZ;
Philippe Mathieu-Daudé Sept. 27, 2021, 5:53 p.m. UTC | #2
On 9/27/21 17:50, Christian Schoenebeck wrote:
> Use QEMU_ALIGN_DOWN() macro to reduce code and to make it
> more human readable.
> 
> Suggested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---
>  hw/9pfs/9p.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff mbox series

Patch

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index c65584173a..29cc19c90a 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1280,8 +1280,7 @@  static int32_t blksize_to_iounit(const V9fsPDU *pdu, int32_t blksize)
      * as well as less than (client msize - P9_IOHDRSZ)
      */
     if (blksize) {
-        iounit = blksize;
-        iounit *= (s->msize - P9_IOHDRSZ) / blksize;
+        iounit = QEMU_ALIGN_DOWN(s->msize - P9_IOHDRSZ, blksize);
     }
     if (!iounit) {
         iounit = s->msize - P9_IOHDRSZ;