From: Miquel Raynal <miquel.raynal@bootlin.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v7 01/13] lib: strto: parse all lowercase metric prefixes in ustrtoul[l]
Date: Mon, 3 Sep 2018 08:47:39 +0200 [thread overview]
Message-ID: <20180903084739.23c59a0e@xps13> (raw)
In-Reply-To: <60a558fc-8bd2-94b7-0ad7-128e21b7c4e8@denx.de>
Hi Stefan,
Stefan Roese <sr@denx.de> wrote on Sat, 1 Sep 2018 10:43:01 +0200:
> On 31.08.2018 16:57, Miquel Raynal wrote:
> > Both ustrtoul and ustrtoull interpret 1k but not 1m or 1g. Even if the
> > SI symbols for Mega and Giga are 'M' and 'G', certain entries of
> > eg. mtdparts also use (wrongly) the metric prefix 'm' and 'g'.
> > > I do not see how parsing lowercase prefixes could break anything, so
> > parse them like their uppercase counterpart.
> > > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> > lib/strto.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> > > diff --git a/lib/strto.c b/lib/strto.c
> > index 7f6076909a..84f8d92d57 100644
> > --- a/lib/strto.c
> > +++ b/lib/strto.c
> > @@ -87,9 +87,11 @@ unsigned long ustrtoul(const char *cp, char **endp, unsigned int base)
> > unsigned long result = simple_strtoul(cp, endp, base);
> > switch (**endp) {
> > case 'G':
> > + case 'g':
> > result *= 1024;
> > /* fall through */
> > case 'M':
> > + case 'm':
> > result *= 1024;
> > /* fall through */
> > case 'K':
> > @@ -110,9 +112,11 @@ unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base)
> > unsigned long long result = simple_strtoull(cp, endp, base);
> > switch (**endp) {
> > case 'G':
> > + case 'g':
> > result *= 1024;
> > /* fall through */
> > case 'M':
> > + case 'm':
>
> Wouldn't it be better, to use tolower() on the char and drop all the
> upper case checks completely - also for the 'K' case?
Sure, I can do that!
Thanks,
Miquèl
next prev parent reply other threads:[~2018-09-03 6:47 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-31 14:57 [U-Boot] [PATCH v7 00/13] Cleaner MTD devices management Miquel Raynal
2018-08-31 14:57 ` [U-Boot] [PATCH v7 01/13] lib: strto: parse all lowercase metric prefixes in ustrtoul[l] Miquel Raynal
2018-09-01 8:43 ` Stefan Roese
2018-09-03 6:47 ` Miquel Raynal [this message]
2018-08-31 14:57 ` [U-Boot] [PATCH v7 02/13] lib: strto: fix metric suffix parsing in strtoul[l] Miquel Raynal
2018-09-01 8:48 ` Stefan Roese
2018-09-03 6:49 ` Miquel Raynal
2018-09-03 7:41 ` Stefan
2018-08-31 14:57 ` [U-Boot] [PATCH v7 03/13] mtd: Kconfig: remove MTD_PARTITIONS duplicated symbol Miquel Raynal
2018-09-01 8:48 ` Stefan Roese
2018-08-31 14:57 ` [U-Boot] [PATCH v7 04/13] cmd: mtdparts: accept spi-nand devices Miquel Raynal
2018-09-01 8:49 ` Stefan Roese
2018-08-31 14:57 ` [U-Boot] [PATCH v7 05/13] cmd: mtdparts: remove mandatory 'mtdparts=' prefix Miquel Raynal
2018-09-01 8:50 ` Stefan Roese
2018-09-03 7:13 ` Miquel Raynal
2018-08-31 14:57 ` [U-Boot] [PATCH v7 06/13] mtd: uclass: add probe function Miquel Raynal
2018-09-01 8:51 ` Stefan Roese
2018-08-31 14:57 ` [U-Boot] [PATCH v7 07/13] mtd: uclass: add a generic 'mtdparts' parser Miquel Raynal
2018-09-01 8:52 ` Stefan Roese
2018-08-31 14:57 ` [U-Boot] [PATCH v7 08/13] mtd: uclass: search for an equivalent MTD name with the mtdids Miquel Raynal
2018-09-01 8:54 ` Stefan Roese
2018-08-31 14:57 ` [U-Boot] [PATCH v7 09/13] mtd: mtdpart: implement proper partition handling Miquel Raynal
2018-09-01 8:56 ` Stefan Roese
2018-08-31 14:57 ` [U-Boot] [PATCH v7 10/13] cmd: mtd: add 'mtd' command Miquel Raynal
2018-09-01 8:59 ` Stefan Roese
2018-09-03 6:54 ` Miquel Raynal
2018-09-03 7:43 ` Stefan
2018-09-03 8:04 ` Jagan Teki
2018-09-03 8:27 ` Miquel Raynal
2018-08-31 14:57 ` [U-Boot] [PATCH v7 11/13] cmd: mtdparts: try to probe the MTD devices as a fallback Miquel Raynal
2018-09-01 9:02 ` Stefan Roese
2018-09-03 7:02 ` Miquel Raynal
2018-08-31 14:57 ` [U-Boot] [PATCH v7 12/13] cmd: ubi: clean the partition handling Miquel Raynal
2018-09-01 9:03 ` Stefan Roese
2018-08-31 14:57 ` [U-Boot] [PATCH v7 13/13] cmd: mtdparts: describe as legacy Miquel Raynal
2018-09-01 9:04 ` Stefan Roese
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180903084739.23c59a0e@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox