[U-Boot] PATCH-add "0X" hexadecimal prefix to simple_strtoul

Wolfgang Denk
2011-02-08T19:14:47Z

Dear Rob Alexander,

In message <4D51716D.3060002@motorola.com> you wrote:
> Added support to simple_strtoul to support the standard 0X hex notation. This issue
> was causing operational bug in U-boot console commands where "0X" hex numbers were being
> misinterpreted as decimal.

Can you please provide an example where such problems happened?

> Signed-off-by: Rob Alexander<robert.b.alexander@motorola.com>
> --- vsprintf.org.c 2011-02-08 10:12:35.954644500 -0600
> +++ vsprintf.c 2011-02-08 10:26:01.708224300 -0600
> @@ -41,8 +41,9 @@
> unsigned long result = 0,value;
>
> if (*cp == '0') {
> - cp++;
> - if ((*cp == 'x')&& isxdigit(cp[1])) {
> + cp++;
> + //support both 0X and 0x notation

ERROR: do not use C99 // comments

> + if ((tolower(*cp) == 'x')&& isxdigit(cp[1])) {

ERROR: spaces required around that '&&' (ctx:VxW)

> base = 16;
> cp++;
> }
> @@ -99,7 +100,8 @@
>
> if (*cp == '0') {
> cp++;
> - if ((*cp == 'x')&& isxdigit (cp[1])) {
> + //support both 0X and 0x notation
> + if ((tolower(*cp) == 'x')&& isxdigit(cp[1]))

Ditto.

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Reader, suppose you were an idiot. And suppose you were a member of
Congress. But I repeat myself. - Mark Twain