Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iLNAV-00029l-LW for mharc-grub-devel@gnu.org; Fri, 18 Oct 2019 03:59:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34115) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLNAQ-00027Y-Fl for grub-devel@gnu.org; Fri, 18 Oct 2019 03:59:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLNAP-0005JA-CN for grub-devel@gnu.org; Fri, 18 Oct 2019 03:59:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57506) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iLNAP-0005Ir-44 for grub-devel@gnu.org; Fri, 18 Oct 2019 03:59:21 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3760EC05AA63 for ; Fri, 18 Oct 2019 07:59:20 +0000 (UTC) Received: by mail-wr1-f70.google.com with SMTP id m14so2200785wru.17 for ; Fri, 18 Oct 2019 00:59:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3tJiO8w9A8DmAE1/lXFvjxUUsb5Ap8+VLYmr1dZt0us=; b=mztIkZEDcMV2acNj6x8TCAz4D6ZDDU7eprrtNTLi9e3ZX38ka9r+c6bRvjItPfrUqp 10Q8YeLN6OImJfaPkxSlXL7+TMUn5EbDnOGYc51Vta+qZdFyIDN0UkFcz7zvPHu0+CSd qukX7KULWCoImyCnVc/w8ui5eO+ZSlDTMHtt3upOlq3rH7qlEkEjzXZavJTG9AbRiz0h M38E6dOpJre+S0VgrIae4YxRfvMkVdYEAWHhKClJgqg2FPtRXAlUNnPVLuwoIsFNCSa8 k1fPBcC9mZ524NLhLy6ybHFqiHM2vYbP2Drb5OCYR3kjYmhRzh7n/gCXkUnUE054o2qr xVTw== X-Gm-Message-State: APjAAAUoxOC/LdEkTXP7WSSomsZ2ejgQfF0t6vAbHwn1NwsuuBjHV01Q X+WJBYkY1ACLs0oMlnYp7zHcPT06MAt4oN46S5sR4J3zFTB0euaImpmLsjciB6AIN187CBnSMSD RSRPxBSTdV7o= X-Received: by 2002:adf:de84:: with SMTP id w4mr1399048wrl.342.1571385558565; Fri, 18 Oct 2019 00:59:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwk3aJeZrVhXhJwpnXItcEaApKWrzhEemxHnNUWWsCtQn5SXsKOF89GIevwiOEd/2Vivhczqw== X-Received: by 2002:adf:de84:: with SMTP id w4mr1399033wrl.342.1571385558347; Fri, 18 Oct 2019 00:59:18 -0700 (PDT) Received: from minerva.redhat.com ([90.168.169.92]) by smtp.gmail.com with ESMTPSA id z22sm5198245wmf.2.2019.10.18.00.59.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2019 00:59:17 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Vladimir Serbinenko , Daniel Kiper , Paulo Flabiano Smorigo , Javier Martinez Canillas Subject: [PATCH v2 1/3] Add %X option to printf functions Date: Fri, 18 Oct 2019 09:59:08 +0200 Message-Id: <20191018075910.31263-2-javierm@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191018075910.31263-1-javierm@redhat.com> References: <20191018075910.31263-1-javierm@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Fri, 18 Oct 2019 07:59:23 -0000 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 Reviewed-by: Daniel Kiper --- Changes in v2: - Put patch that adds the %X format specifier first in the series. 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 =3D (c =3D=3D 'x') ? 16 : 10; + unsigned base =3D ((c =3D=3D 'x') || (c =3D=3D 'X')) ? 16 : 10; char *p; =20 if ((long long) n < 0 && c =3D=3D 'd') @@ -603,7 +603,7 @@ grub_lltoa (char *str, int c, unsigned long long n) do { unsigned d =3D (unsigned) (n & 0xf); - *p++ =3D (d > 9) ? d + 'a' - 10 : d + '0'; + *p++ =3D (d > 9) ? d + ((c =3D=3D 'x') ? 'a' : 'A') - 10 : d + '0'; } while (n >>=3D 4); else @@ -676,6 +676,7 @@ parse_printf_args (const char *fmt0, struct printf_ar= gs *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_ar= gs *args, switch (c) { case 'x': + case 'X': case 'u': args->ptr[curn].type =3D UNSIGNED_INT + longfmt; break; @@ -900,6 +902,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, = const char *fmt0, c =3D 'x'; /* Fall through. */ case 'x': + case 'X': case 'u': case 'd': { --=20 2.21.0