On Feb 9, 2012, at 11:01 AM, Jeremy Jackson wrote:

> Vasily,
> 
> I think you're looking at the wrong thing.

Right, wrong thing :) 

> It's not ('A' - '0' + 10) & 0xf, 
> it's actually:
>  ('A' - 'a' + 10) & 0xf 
> OR
> ('A' - 'A' + 10) & 0xf, right?
> 
> i.e., (c - 'A' + 10) & 0xf, where c == 'A',
> 
> I thought it should be (c - 'a' + 10) & 0xf, because NUM_2_HEX provides the 
> lowercase equivalent:
> 

what the difference which case of the number ?

> '0' + (b) + 39, 
> where b > 9.
> So '0' + 10 + 39 = '0' + 49 = 97 == 'a'
> 
> On Thu, Feb 9, 2012 at 12:51 AM, Vasily Levchenko 
> <[email protected]> wrote:
> Hi, Jeremy,
> Thanks for reading  VBox source code, but the lowercase or upper case doesn't 
> meter here, it's easy to check with gdb
> (gdb) p /x ('A' - '0' + 10) & 0xf
> $2 = 0xb
> (gdb) p /x ('a' - '0' + 10) & 0xf
> $3 = 0xb
> And looks like  they are both incorrect, should be
> (gdb) p /x ('A' - '0' + 9) & 0xf
> $5 = 0xa
> On Feb 9, 2012, at 8:26 AM, Jeremy Jackson wrote:
> 
> > I believe the HEX_2_NUM is incorrect, and should be converting lowercase 
> > hex values, since NUM_2_HEX creates lowercase hex values.
> >
> > I have pasted the output of my patch:
> >
> > ~/code/vbox/src $ cat patch.diff
> > Index: VBox/Storage/ISCSI.cpp
> > ===================================================================
> > --- VBox/Storage/ISCSI.cpp      (revision 40038)
> > +++ VBox/Storage/ISCSI.cpp      (working copy)
> > @@ -51,7 +51,7 @@
> >  /** Converts a number in the range of 0 - 15 into the corresponding hex 
> > char. */
> >  #define NUM_2_HEX(b) ('0' + (b) + (((b) > 9) ? 39 : 0))
> >  /** Converts a hex char into the corresponding number in the range 0-15. */
> > -#define HEX_2_NUM(c) (((c) <= '9') ? ((c) - '0') : (((c - 'A' + 10) & 
> > 0xf)))
> > +#define HEX_2_NUM(c) (((c) <= '9') ? ((c) - '0') : (((c - 'a' + 10) & 
> > 0xf)))
> >  /* Converts a base64 char into the corresponding number in the range 0-63. 
> > */
> >  #define B64_2_NUM(c) ((c >= 'A' && c <= 'Z') ? (c - 'A') : (c >= 'a' && c 
> > <= 'z') ? (c - 'a' + 26) : (c >= '0' && c <= '9') ? (c - '0' + 52) : (c == 
> > '+') ? 62 : (c == '/') ? 63 : -1)
> > _______________________________________________
> > vbox-dev mailing list
> > [email protected]
> > https://www.virtualbox.org/mailman/listinfo/vbox-dev
> 
> 

_______________________________________________
vbox-dev mailing list
[email protected]
https://www.virtualbox.org/mailman/listinfo/vbox-dev

Reply via email to