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

login
register
mail settings
Submitter Rob Alexander
Date Feb. 8, 2011, 4:38 p.m.
Message ID <4D51716D.3060002@motorola.com>
Download mbox | patch
Permalink /patch/82362/
State Changes Requested
Headers show

Comments

Rob Alexander - Feb. 8, 2011, 4:38 p.m.
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.

Signed-off-by: Rob Alexander<robert.b.alexander@motorola.com>
Wolfgang Denk - Feb. 8, 2011, 7:14 p.m.
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
Chris Moore - Feb. 9, 2011, 6:19 a.m.
Hi,

Le 08/02/2011 20:14, Wolfgang Denk a écrit :
> Dear Rob Alexander,
>
> In message<4D51716D.3060002@motorola.com>  you wrote:
>
>> +		if ((tolower(*cp) == 'x')&&   isxdigit(cp[1])) {
> ERROR: spaces required around that '&&' (ctx:VxW)
>

I suspect that this could be the Thunderbird problem that Albert noticed 
the other day.
Some versions of TB seem to eat the space before an '&' character and 
IIRC also before at least one of the '<' and '>' characters :(

I also noticed this in some of my (rare) posts.
I am using TB 3.1.5.
I am too ashamed to admit my OS ;-)

A nonsense test case written with correct spacing: a = (b > (c >> 1)) && 
((d < ((e & 1) << 1)));
If you receive this correctly then please excuse me for the noise :(

Cheers,
Chris
Albert ARIBAUD - Feb. 9, 2011, 6:40 a.m.
Le 09/02/2011 07:19, Chris Moore a écrit :
> Hi,
>
> Le 08/02/2011 20:14, Wolfgang Denk a écrit :
>> Dear Rob Alexander,
>>
>> In message<4D51716D.3060002@motorola.com> you wrote:
>>
>>> + if ((tolower(*cp) == 'x')&& isxdigit(cp[1])) {
>> ERROR: spaces required around that '&&' (ctx:VxW)
>>
>
> I suspect that this could be the Thunderbird problem that Albert noticed
> the other day.
> Some versions of TB seem to eat the space before an '&' character and
> IIRC also before at least one of the '<' and '>' characters :(

Not only. From time to time I see spaces missing between simple words in 
the subjects pane of the UI while the actual message does have the 
space, meaning TB wrongly removes spaces at the receiving end, not the 
sending end.

> I also noticed this in some of my (rare) posts.
> I am using TB 3.1.5.
> I am too ashamed to admit my OS ;-)
>
> A nonsense test case written with correct spacing: a = (b > (c >> 1)) &&
> ((d < ((e & 1) << 1)));
> If you receive this correctly then please excuse me for the noise :(

Received correctly. :)

In Rob's case I am not sure that the issue is due to TB eating selected 
spaces upon reception; my own TB (3.1.7), using ^U to display the raw 
message from Rob, shows missing spaces are actually in what was sent, 
and I think Wolfgang does not use TB at all.

Amicalement,
Scott Wood - Feb. 9, 2011, 9:17 p.m.
On Wed, 9 Feb 2011 07:40:44 +0100
Albert ARIBAUD <albert.aribaud@free.fr> wrote:

> Le 09/02/2011 07:19, Chris Moore a écrit :
> > I also noticed this in some of my (rare) posts.
> > I am using TB 3.1.5.
> > I am too ashamed to admit my OS ;-)
> >
> > A nonsense test case written with correct spacing: a = (b > (c >> 1)) &&
> > ((d < ((e & 1) << 1)));
> > If you receive this correctly then please excuse me for the noise :(
> 
> Received correctly. :)
> 
> In Rob's case I am not sure that the issue is due to TB eating selected 
> spaces upon reception; my own TB (3.1.7), using ^U to display the raw 
> message from Rob, shows missing spaces are actually in what was sent, 
> and I think Wolfgang does not use TB at all.

It's when quoting a message for a reply that Thunderbird does this mangling.

-Scott
Chris Moore - Feb. 10, 2011, 6:16 a.m.
Hi,

Le 09/02/2011 22:17, Scott Wood a écrit :
> On Wed, 9 Feb 2011 07:40:44 +0100
> Albert ARIBAUD<albert.aribaud@free.fr>  wrote:
>
>> Le 09/02/2011 07:19, Chris Moore a écrit :
>>> I also noticed this in some of my (rare) posts.
>>> I am using TB 3.1.5.
>>> I am too ashamed to admit my OS ;-)
>>>
>>> A nonsense test case written with correct spacing: a = (b>  (c>>  1))&&
>>> ((d<  ((e&  1)<<  1)));
>>> If you receive this correctly then please excuse me for the noise :(
>> Received correctly. :)
>>
>> In Rob's case I am not sure that the issue is due to TB eating selected
>> spaces upon reception; my own TB (3.1.7), using ^U to display the raw
>> message from Rob, shows missing spaces are actually in what was sent,
>> and I think Wolfgang does not use TB at all.
> It's when quoting a message for a reply that Thunderbird does this mangling.
>

Right, that would seem to be this bug: 
https://bugzilla.mozilla.org/show_bug.cgi?id=448198
I have certainly encountered this one when quoting :(

But there is also: https://bugzilla.mozilla.org/show_bug.cgi?id=597181
I wonder if I haven't run into this one too :(

Cheers,
Chris
Chris Moore - Feb. 10, 2011, 6:22 a.m.
Hi,

Me again.

Le 10/02/2011 07:16, Chris Moore a écrit :
> Hi,
>
> Le 09/02/2011 22:17, Scott Wood a écrit :
>> On Wed, 9 Feb 2011 07:40:44 +0100
>> Albert ARIBAUD<albert.aribaud@free.fr>   wrote:
>>
>>> Le 09/02/2011 07:19, Chris Moore a écrit :
>>>> I also noticed this in some of my (rare) posts.
>>>> I am using TB 3.1.5.
>>>> I am too ashamed to admit my OS ;-)
>>>>
>>>> A nonsense test case written with correct spacing: a = (b>   (c>>   1))&&
>>>> ((d<   ((e&   1)<<   1)));
>>>> If you receive this correctly then please excuse me for the noise :(
>>> Received correctly. :)
>>>
>>> In Rob's case I am not sure that the issue is due to TB eating selected
>>> spaces upon reception; my own TB (3.1.7), using ^U to display the raw
>>> message from Rob, shows missing spaces are actually in what was sent,
>>> and I think Wolfgang does not use TB at all.
>> It's when quoting a message for a reply that Thunderbird does this mangling.
>>
> Right, that would seem to be this bug:
> https://bugzilla.mozilla.org/show_bug.cgi?id=448198
> I have certainly encountered this one when quoting :(
>
> But there is also: https://bugzilla.mozilla.org/show_bug.cgi?id=597181
> I wonder if I haven't run into this one too :(

Note that my reply introduced the quoted text bug in my test case above :(

Cheers,
Chris
Reinhard Meyer - Feb. 10, 2011, 6:28 a.m.
Dear Chris Moore,
> Hi,
>
> Me again.
>
> Le 10/02/2011 07:16, Chris Moore a écrit :
>> Hi,
>>
>> Le 09/02/2011 22:17, Scott Wood a écrit :
>>> On Wed, 9 Feb 2011 07:40:44 +0100
>>> Albert ARIBAUD<albert.aribaud@free.fr>    wrote:
>>>
>>>> Le 09/02/2011 07:19, Chris Moore a écrit :
>>>>> I also noticed this in some of my (rare) posts.
>>>>> I am using TB 3.1.5.
>>>>> I am too ashamed to admit my OS ;-)
>>>>>
>>>>> A nonsense test case written with correct spacing: a = (b>    (c>>    1))&&
>>>>> ((d<    ((e&    1)<<    1)));
>>>>> If you receive this correctly then please excuse me for the noise :(
>>>> Received correctly. :)
>>>>
>>>> In Rob's case I am not sure that the issue is due to TB eating selected
>>>> spaces upon reception; my own TB (3.1.7), using ^U to display the raw
>>>> message from Rob, shows missing spaces are actually in what was sent,
>>>> and I think Wolfgang does not use TB at all.
>>> It's when quoting a message for a reply that Thunderbird does this mangling.
>>>
>> Right, that would seem to be this bug:
>> https://bugzilla.mozilla.org/show_bug.cgi?id=448198
>> I have certainly encountered this one when quoting :(
>>
>> But there is also: https://bugzilla.mozilla.org/show_bug.cgi?id=597181
>> I wonder if I haven't run into this one too :(
>
> Note that my reply introduced the quoted text bug in my test case above :(

The space mangling even happens when one saves an e-mail (e.g. a patch).
I am glad we now have patchwork to download patches... Before I used an old
(theoretical insecure) thunderbird version to do that.

Best Regards,
Reinhard

Patch

--- 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
+		if ((tolower(*cp) == 'x')&&  isxdigit(cp[1])) {
  			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]))
  			base = 16;
  			cp++;
  		}