From 1acb1d9dae8192e72e3de7ac826f47263fe280c5 Mon Sep 17 00:00:00 2001 From: Nigel Croxon Date: Fri, 25 Mar 2016 10:28:02 -0400 Subject: [PATCH] %d now represents signed decimal, %u represents unsigned decimal. This patch changes the behavior of Print() slightly. %d is now signed decimal, and %u (new) is unsigned decimal. Previously, although ValueToString supports signed decimal printing, %d always read args as UINTxx. Old behavior: Print(L"%d\n", -4) -> "4294967292" New behavior: Print(L"%d\n, -4) -> "-4" Print(L"%u\n", -4) -> "4294967292" If you want to keep complete backwards compatibility you could leave %d alone and make something else (probably shouldn't be %u to avoid confusion) be signed decimal. But this way it agrees with the usual use of %d and %u. Signed-off-by: Nathan Blythe Signed-off-by: Nigel Croxon --- lib/print.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/print.c b/lib/print.c index b9bbf60..ee1c775 100644 --- a/lib/print.c +++ b/lib/print.c @@ -998,7 +998,8 @@ Routine Description: s - unicode string X - fixed 8 byte value in hex x - hex value - d - value as decimal + d - value as signed decimal + u - value as unsigned decimal c - Unicode char t - EFI time structure g - Pointer to GUID @@ -1144,15 +1145,24 @@ Returns: GuidToString (Item.Item.pw, va_arg(ps->args, EFI_GUID *)); break; - case 'd': + case 'u': Item.Item.pw = Item.Scratch; ValueToString ( Item.Item.pw, Item.Comma, Item.Long ? va_arg(ps->args, UINT64) : va_arg(ps->args, UINT32) ); - break - ; + break; + + case 'd': + Item.Item.pw = Item.Scratch; + ValueToString ( + Item.Item.pw, + Item.Comma, + Item.Long ? va_arg(ps->args, INT64) : va_arg(ps->args, INT32) + ); + break; + case 't': Item.Item.pw = Item.Scratch; TimeToString (Item.Item.pw, va_arg(ps->args, EFI_TIME *));