printk: print pointers on 64-bit properly

Needs a min-width of 16, not 8, for 64-bit.
Some indentation oddities fixed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2019-11-05 13:28:17 -08:00 committed by Andrew Boie
commit ec3aafbf78
2 changed files with 12 additions and 8 deletions

View file

@ -219,12 +219,16 @@ void z_vprintk(out_func_t out, void *ctx, const char *fmt, va_list ap)
break;
}
case 'p':
out('0', ctx);
out('x', ctx);
/* left-pad pointers with zeros */
padding = PAD_ZERO_BEFORE;
min_width = 8;
/* Fall through */
out('0', ctx);
out('x', ctx);
/* left-pad pointers with zeros */
padding = PAD_ZERO_BEFORE;
if (IS_ENABLED(CONFIG_64BIT)) {
min_width = 16;
} else {
min_width = 8;
}
/* Fall through */
case 'x':
case 'X': {
unsigned long long x;

View file

@ -33,14 +33,14 @@ char *expected = "22 113 10000 32768 40000 22\n"
char *expected = "22 113 10000 32768 40000 22\n"
"p 112 -10000 -32768 -40000 -22\n"
"0xcafebabe 0x0000beef\n"
"0xcafebabe 0x000000000000beef\n"
"0x1 0x01 0x0001 0x00000001 0x0000000000000001\n"
"0x1 0x 1 0x 1 0x 1\n"
"42 42 0042 00000042\n"
"-42 -42 -042 -0000042\n"
"42 42 42 42\n"
"42 42 0042 00000042\n"
"255 42 abcdef 0x0000002a 42\n"
"255 42 abcdef 0x000000000000002a 42\n"
"68719476735 -1 18446744073709551615 ffffffffffffffff\n"
;
#endif