Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iuDmC-00078b-Kj for mharc-grub-devel@gnu.org; Wed, 22 Jan 2020 06:02:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33904) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuDm8-000750-Tf for grub-devel@gnu.org; Wed, 22 Jan 2020 06:02:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuDm7-0001Gw-SA for grub-devel@gnu.org; Wed, 22 Jan 2020 06:02:20 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:55924 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuDm7-0001GL-O5 for grub-devel@gnu.org; Wed, 22 Jan 2020 06:02:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579690939; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aEhBaMSuG3RnRyV2ZdkVEFOotaUECIxZ9VKSW/TezYU=; b=euPqjZWQBcy7rn8NsLikAmspYT0A4xE5Zs8t73iWZ1y5THEgmAhin+/pCcBg5t9+BUwijy AoFwz0LWUUrmu/zbNXkTCjPSQpw8FG8k8+dbLl5AxE5MM9q3FOdHxDjtN6Snqh47gO/UWo VOaNo6JZWmLWuQYCv+Wj4tU8baDLbrA= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-14-sKP1hX6ENOyG2yEXqXKPLg-1; Wed, 22 Jan 2020 06:02:15 -0500 Received: by mail-wr1-f70.google.com with SMTP id f10so2873488wro.14 for ; Wed, 22 Jan 2020 03:02:14 -0800 (PST) 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=2noyMzYdtqVUapvlT7niSNx63DN/tcYRVDkEoVcecPU=; b=H+eK5bqpTivrvqDCt8+6+ztZaAGHqk+mnmM1BkeJgRZQ0LXQ6CLlXosEESwFVSGAS7 +mMLqVo4CWPjHkWQsSmrKGtDpaXkKDCx41rJzFJ8lN7qZq3DVkQD+BhDa+iWgNyJ64vs p7RmyyrHJMUXyCaIyryQg31g71h+StLSeRN3JeiwXdwBH5elC/GKfQBTgf0KTM6DGd4R 2yCB8wgXso/vZQEcWsFulvL+glKR6XPNcFTHfO39SiR0gRk6f1qxawyAemp2cGjYtpmN NBwoiLrEyaS01nye8tY1LLy3f4E6jivArAANeqZYFU7rvXPXrR0+4uMW3jd4svoeSFiA vtoQ== X-Gm-Message-State: APjAAAWI+JVoDutpKPxhs268jQG9/xHb9GKcuwwEPLWYWb41qC0qWUnW 8vXRknDxEnxs4oq3ounabKwzpWmQkIH7p+9lW0nPAplDOimYelCVXCrW1B4Ms1ZJtqQ5w+0ezsh /it8cFSTk5HM= X-Received: by 2002:adf:ce87:: with SMTP id r7mr10471441wrn.245.1579690933437; Wed, 22 Jan 2020 03:02:13 -0800 (PST) X-Google-Smtp-Source: APXvYqxV8WhPId+IzKloCl48J9BN2kdXxoeeqPjq5t9J7iE60qsiL12xoK82XL4c0D67I1PTDJ5Obw== X-Received: by 2002:adf:ce87:: with SMTP id r7mr10471406wrn.245.1579690933161; Wed, 22 Jan 2020 03:02:13 -0800 (PST) Received: from minerva.redhat.com ([2a01:c50f:ab80:6700:527f:85b3:5615:ff0b]) by smtp.gmail.com with ESMTPSA id c2sm56546692wrp.46.2020.01.22.03.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 03:02:11 -0800 (PST) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Daniel Kiper , Paulo Flabiano Smorigo , Vladimir Serbinenko , Javier Martinez Canillas Subject: [PATCH v6 1/5] Add %X option to printf functions Date: Wed, 22 Jan 2020 12:01:52 +0100 Message-Id: <20200122110157.1062269-2-javierm@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200122110157.1062269-1-javierm@redhat.com> References: <20200122110157.1062269-1-javierm@redhat.com> MIME-Version: 1.0 X-MC-Unique: sKP1hX6ENOyG2yEXqXKPLg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII 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: 205.139.110.61 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: Wed, 22 Jan 2020 11:02:22 -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 v6: None Changes in v5: None Changes in v4: None Changes in v3: None 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_u= int64_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 { =09unsigned d =3D (unsigned) (n & 0xf); -=09*p++ =3D (d > 9) ? d + 'a' - 10 : d + '0'; +=09*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_args= *args, =09{ =09case 'p': =09case 'x': +=09case 'X': =09case 'u': =09case 'd': =09case 'c': @@ -762,6 +763,7 @@ parse_printf_args (const char *fmt0, struct printf_args= *args, switch (c) =09{ =09case 'x': +=09case 'X': =09case 'u': =09 args->ptr[curn].type =3D UNSIGNED_INT + longfmt; =09 break; @@ -900,6 +902,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, co= nst char *fmt0, =09 c =3D 'x'; =09 /* Fall through. */ =09case 'x': +=09case 'X': =09case 'u': =09case 'd': =09 { --=20 2.24.1