On Mon, Mar 11, 2019 at 03:05:19PM +0000, Colin Watson wrote: >This is needed for UEFI Boot* variables, which the standard says are >named using upper-case hexadecimal. >--- > grub-core/kern/misc.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > >diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c >index 3b633d51f..73f8e0e9e 100644 >--- a/grub-core/kern/misc.c >+++ b/grub-core/kern/misc.c >@@ -588,7 +588,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, >grub_uint64_t *r) > static inline char * > grub_lltoa (char *str, int c, unsigned long long n) > { >- unsigned base = (c == 'x') ? 16 : 10; >+ unsigned base = (c == 'x' || c == 'X') ? 16 : 10; > char *p; > > if ((long long) n < 0 && c == 'd') >@@ -603,7 +603,10 @@ grub_lltoa (char *str, int c, unsigned long long n) > do > { > unsigned d = (unsigned) (n & 0xf); >- *p++ = (d > 9) ? d + 'a' - 10 : d + '0'; >+ *p = (d > 9) ? d + 'a' - 10 : d + '0'; >+ if (c == 'X') >+ *p = grub_toupper (*p); >+ p++;
I'd be more tempted to simply do the upper-case stuff using if (c == 'x') *p++ = (d > 9) ? d + 'a' - 10 : d + '0'; else *p++ = (d > 9) ? d + 'A' - 10 : d + '0'; fi rather than the call out to grub_toupper(), but that's just minor nit-picking on style. > } > while (n >>= 4); > else >@@ -676,6 +679,7 @@ parse_printf_args (const char *fmt0, struct printf_args >*args, > { > case 'p': > case 'x': >+ case 'X': > case 'u': > case 'd': > case 'c': >@@ -762,6 +766,7 @@ parse_printf_args (const char *fmt0, struct printf_args >*args, > switch (c) > { > case 'x': >+ case 'X': > case 'u': > args->ptr[curn].type = UNSIGNED_INT + longfmt; > break; >@@ -900,6 +905,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const >char *fmt0, > c = 'x'; > /* Fall through. */ > case 'x': >+ case 'X': > case 'u': > case 'd': > { >-- >2.17.1 Reviewed-by: Steve McIntyre <93...@debian.org> -- Steve McIntyre, Cambridge, UK. st...@einval.com "Because heaters aren't purple!" -- Catherine Pitt _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel