diff mbox

[PULL,05/15] translate-all: Fix formatting of dump output

Message ID 1379188061-7634-6-git-send-email-mjt@msgid.tls.msk.ru
State New
Headers show

Commit Message

Michael Tokarev Sept. 14, 2013, 7:47 p.m. UTC
From: Stefan Weil <sw@weilnetz.de>

The page dump writes a table with 3 abi_ulong values in each row.
These values take 8 or 16 characters (depending on sizeof abi_ulong).

Fix the table headings to be aligned with the table columns.

old:
start    end      size     prot
0000000120000000-000000012021e000 000000000021e000 rwx
0000004000000000-0000004000002000 0000000000002000 ---
0000004000002000-0000004000802000 0000000000800000 rw-

new:
start            end              size             prot
0000000120000000-000000012021e000 000000000021e000 rwx
0000004000000000-0000004000002000 0000000000002000 ---
0000004000002000-0000004000802000 0000000000800000 rw-

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 translate-all.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Stefan Weil Sept. 17, 2013, 5:59 p.m. UTC | #1
Am 14.09.2013 21:47, schrieb Michael Tokarev:
> From: Stefan Weil <sw@weilnetz.de>
>
> The page dump writes a table with 3 abi_ulong values in each row.
> These values take 8 or 16 characters (depending on sizeof abi_ulong).
>
> Fix the table headings to be aligned with the table columns.
>
> old:
> start    end      size     prot
> 0000000120000000-000000012021e000 000000000021e000 rwx
> 0000004000000000-0000004000002000 0000000000002000 ---
> 0000004000002000-0000004000802000 0000000000800000 rw-
>
> new:
> start            end              size             prot
> 0000000120000000-000000012021e000 000000000021e000 rwx
> 0000004000000000-0000004000002000 0000000000002000 ---
> 0000004000002000-0000004000802000 0000000000800000 rw-
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> ---
>  translate-all.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/translate-all.c b/translate-all.c
> index 2c923c6..3b97c66 100644
> --- a/translate-all.c
> +++ b/translate-all.c
> @@ -1679,8 +1679,9 @@ static int dump_region(void *priv, abi_ulong start,
>  /* dump memory mappings */
>  void page_dump(FILE *f)
>  {
> -    (void) fprintf(f, "%-8s %-8s %-8s %s\n",
> -            "start", "end", "size", "prot");
> +    const size_t length = sizeof(abi_ulong) * 2;
> +    (void) fprintf(f, "%-*s %-*s %-*s %s\n",
> +            length, "start", length, "end", length, "size", "prot");
>      walk_memory_regions(f, dump_region);
>  }
>  

Sorry, I just noticed that this patch causes compiler warnings on some
systems:

translate-all.c:1684:13: error: field width specifier ‘*’ expects
argument of type ‘int’, but argument 3 has type ‘size_t’ [-Werror=format]
translate-all.c:1684:13: error: field width specifier ‘*’ expects
argument of type ‘int’, but argument 5 has type ‘size_t’ [-Werror=format]
translate-all.c:1684:13: error: field width specifier ‘*’ expects
argument of type ‘int’, but argument 7 has type ‘size_t’ [-Werror=format]

Changing the type of variable 'length' to int fixes this:

+    const int length = sizeof(abi_ulong) * 2;


Regards,
Stefan
diff mbox

Patch

diff --git a/translate-all.c b/translate-all.c
index 2c923c6..3b97c66 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -1679,8 +1679,9 @@  static int dump_region(void *priv, abi_ulong start,
 /* dump memory mappings */
 void page_dump(FILE *f)
 {
-    (void) fprintf(f, "%-8s %-8s %-8s %s\n",
-            "start", "end", "size", "prot");
+    const size_t length = sizeof(abi_ulong) * 2;
+    (void) fprintf(f, "%-*s %-*s %-*s %s\n",
+            length, "start", length, "end", length, "size", "prot");
     walk_memory_regions(f, dump_region);
 }