diff mbox

memory: Fix zero-sized memory region print

Message ID 20130719184124.15864.20803.stgit@bling.home
State New
Headers show

Commit Message

Alex Williamson July 19, 2013, 6:42 p.m. UTC
if mr->size == 0, then

int128_get64(int128_sub(mr->size, int128_make64(1))) => assert(!a.hi)

Also, use int128_one().

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 memory.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Paolo Bonzini July 19, 2013, 8:09 p.m. UTC | #1
Il 19/07/2013 20:42, Alex Williamson ha scritto:
> if mr->size == 0, then
> 
> int128_get64(int128_sub(mr->size, int128_make64(1))) => assert(!a.hi)
> 
> Also, use int128_one().
> 
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

> ---
>  memory.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/memory.c b/memory.c
> index c8f9a2b..6e17c21 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1788,7 +1788,9 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
>                     "-" TARGET_FMT_plx "\n",
>                     base + mr->addr,
>                     base + mr->addr
> -                   + (hwaddr)int128_get64(int128_sub(mr->size, int128_make64(1))),
> +                   + (int128_nz(mr->size) ?
> +                      (hwaddr)int128_get64(int128_sub(mr->size,
> +                                                      int128_one())) : 0),
>                     mr->priority,
>                     mr->romd_mode ? 'R' : '-',
>                     !mr->readonly && !(mr->rom_device && mr->romd_mode) ? 'W'
> @@ -1803,7 +1805,9 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
>                     TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %c%c): %s\n",
>                     base + mr->addr,
>                     base + mr->addr
> -                   + (hwaddr)int128_get64(int128_sub(mr->size, int128_make64(1))),
> +                   + (int128_nz(mr->size) ?
> +                      (hwaddr)int128_get64(int128_sub(mr->size,
> +                                                      int128_one())) : 0),
>                     mr->priority,
>                     mr->romd_mode ? 'R' : '-',
>                     !mr->readonly && !(mr->rom_device && mr->romd_mode) ? 'W'
>
Anthony Liguori July 23, 2013, 7:04 p.m. UTC | #2
Applied.  Thanks.

Regards,

Anthony Liguori
diff mbox

Patch

diff --git a/memory.c b/memory.c
index c8f9a2b..6e17c21 100644
--- a/memory.c
+++ b/memory.c
@@ -1788,7 +1788,9 @@  static void mtree_print_mr(fprintf_function mon_printf, void *f,
                    "-" TARGET_FMT_plx "\n",
                    base + mr->addr,
                    base + mr->addr
-                   + (hwaddr)int128_get64(int128_sub(mr->size, int128_make64(1))),
+                   + (int128_nz(mr->size) ?
+                      (hwaddr)int128_get64(int128_sub(mr->size,
+                                                      int128_one())) : 0),
                    mr->priority,
                    mr->romd_mode ? 'R' : '-',
                    !mr->readonly && !(mr->rom_device && mr->romd_mode) ? 'W'
@@ -1803,7 +1805,9 @@  static void mtree_print_mr(fprintf_function mon_printf, void *f,
                    TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %c%c): %s\n",
                    base + mr->addr,
                    base + mr->addr
-                   + (hwaddr)int128_get64(int128_sub(mr->size, int128_make64(1))),
+                   + (int128_nz(mr->size) ?
+                      (hwaddr)int128_get64(int128_sub(mr->size,
+                                                      int128_one())) : 0),
                    mr->priority,
                    mr->romd_mode ? 'R' : '-',
                    !mr->readonly && !(mr->rom_device && mr->romd_mode) ? 'W'