[1/5] libctf: disambiguate hex output in dumps

Message ID 20190630181359.98029-1-nick.alcock@oracle.com
State New
Headers show
Series
  • [1/5] libctf: disambiguate hex output in dumps
Related show

Commit Message

Nick Alcock June 30, 2019, 6:13 p.m.
We were sometimes printing hex values without prefixing them with '0x',
leading to confusion about what base the numbers were actually in.

libctf/
	* ctf-dump.c (ctf_dump_format_type): Prefix hex strings with 0x.
	(ctf_dump_funcs): Likewise.
---
 libctf/ctf-dump.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.22.0.238.g049a27acdc

Comments

Jose E. Marchesi July 1, 2019, 10:15 a.m. | #1
We were sometimes printing hex values without prefixing them with '0x',
    leading to confusion about what base the numbers were actually in.
    
    libctf/
    	* ctf-dump.c (ctf_dump_format_type): Prefix hex strings with 0x.
    	(ctf_dump_funcs): Likewise.

Pushed on your behalf.
Salud!

Patch

diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c
index 3dac435eba..0e8ab202dd 100644
--- a/libctf/ctf-dump.c
+++ b/libctf/ctf-dump.c
@@ -121,7 +121,7 @@  ctf_dump_format_type (ctf_file_t *fp, ctf_id_t id)
 	}
       else
 	{
-	  if (asprintf (&bit, " %lx: %s (size %lx)", id, buf[0] == '\0' ?
+	  if (asprintf (&bit, " %lx: %s (size 0x%lx)", id, buf[0] == '\0' ?
 			"(nameless)" : buf,
 			(unsigned long) ctf_type_size (fp, id)) < 0)
 	    goto oom;
@@ -280,12 +280,12 @@  ctf_dump_funcs (ctf_file_t *fp, ctf_dump_state_t *state)
       sym_name = ctf_lookup_symbol_name (fp, i);
       if (sym_name[0] == '\0')
 	{
-	  if (asprintf (&bit, "%lx ", (unsigned long) i) < 0)
+	  if (asprintf (&bit, "0x%lx ", (unsigned long) i) < 0)
 	    goto oom;
 	}
       else
 	{
-	  if (asprintf (&bit, "%s (%lx) ", sym_name, (unsigned long) i) < 0)
+	  if (asprintf (&bit, "%s (0x%lx) ", sym_name, (unsigned long) i) < 0)
 	    goto oom;
 	}
       str = ctf_str_append (str, bit);