From 88ace0a99fe169ecc087c00afbb71146dd7b2402 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Sun, 10 May 2020 02:31:53 -0700 Subject: [PATCH] Fix a bug in print_long_hex() Because of order of shifting operations and a literal that defaulted to int, the high 32 bits were printed incorrectly. --- src/boot/console.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/boot/console.cpp b/src/boot/console.cpp index 27057e4..8554913 100644 --- a/src/boot/console.cpp +++ b/src/boot/console.cpp @@ -126,7 +126,7 @@ console::print_hex(uint32_t n) const wchar_t buffer[9]; wchar_t *p = buffer; for (int i = 7; i >= 0; --i) { - uint8_t nibble = (n & (0xf << (i*4))) >> (i*4); + uint8_t nibble = (n >> (i*4)) & 0xf; *p++ = digits[nibble]; } *p = 0; @@ -140,7 +140,7 @@ console::print_long_hex(uint64_t n) const wchar_t buffer[17]; wchar_t *p = buffer; for (int i = 15; i >= 0; --i) { - uint8_t nibble = (n & (0xf << (i*4))) >> (i*4); + uint8_t nibble = (n >> (i*4)) & 0xf; *p++ = digits[nibble]; } *p = 0;