From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iGZBE-0005QE-PS for mharc-grub-devel@gnu.org; Fri, 04 Oct 2019 21:48:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33067) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGZBB-0005PW-WB for grub-devel@gnu.org; Fri, 04 Oct 2019 21:48:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGZBA-0001nq-49 for grub-devel@gnu.org; Fri, 04 Oct 2019 21:48:17 -0400 Received: from cheddar.halon.org.uk ([93.93.131.118]:33122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iGZB9-0001kq-Ue for grub-devel@gnu.org; Fri, 04 Oct 2019 21:48:16 -0400 Received: from bsmtp by cheddar.halon.org.uk with local-bsmtp (Exim 4.89) (envelope-from ) id 1iGZB4-0002R1-3f; Sat, 05 Oct 2019 02:48:10 +0100 Received: from steve by tack.einval.org with local (Exim 4.92) (envelope-from ) id 1iGZAJ-0003F1-D6; Sat, 05 Oct 2019 02:47:23 +0100 Date: Sat, 5 Oct 2019 02:47:23 +0100 From: Steve McIntyre To: The development of GNU GRUB Cc: Vladimir Serbinenko , Daniel Kiper , Paulo Flabiano Smorigo , Javier Martinez Canillas Subject: Re: [PATCH 2/3] Add %X option to printf functions Message-ID: <20191005014716.GV5783@tack.einval.com> References: <20191004224427.22480-1-javierm@redhat.com> <20191004224427.22480-3-javierm@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191004224427.22480-3-javierm@redhat.com> X-attached: none User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 93.93.131.118 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Oct 2019 01:48:19 -0000 On Sat, Oct 05, 2019 at 12:44:26AM +0200, Javier Martinez Canillas wrote: >From: Paulo Flabiano Smorigo > >The printf(3) function has support for the %X format specifier, to output >an unsigned hexadecimal integer in uppercase. > >This can be achived in GRUB using the %x format specifier in grub_printf() >and calling grub_toupper(), but it is more convenient if there is support >for %X in grub_printf(). > >Signed-off-by: Paulo Flabiano Smorigo >Signed-off-by: Javier Martinez Canillas >--- > > grub-core/kern/misc.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > >diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c >index 3b633d51f4c..76e7fb22872 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,7 @@ 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 + ((c == 'x') ? 'a' : 'A') - 10 : d + '0'; > } > while (n >>= 4); > else >@@ -676,6 +676,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 +763,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 +902,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': > { Ummm, isn't this exactly the same patch that Colin Watson proposed and I reviewed back in March, as part of his changeset for UEFI? https://lists.gnu.org/archive/html/grub-devel/2019-03/msg00121.html Oh, that never got applied. :-( -- Steve McIntyre, Cambridge, UK. steve@einval.com Mature Sporty Personal More Innovation More Adult A Man in Dandism Powered Midship Specialty