lkml.org 
[lkml]   [2010]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 01/10] lib: introduce common method to convert hex digits
From
Date
On Fri, 2010-04-30 at 12:07 -0700, Andrew Morton wrote:
> I had to fiddle with it:
> - use tolower(), saving 3 bytes!

tolower could be done after the 0-9 case as well

int hex_to_bin(char ch)
{
if ((ch >= '0') && (ch <= '9'))
return ch - '0';
ch = tolower(ch);
if ((ch >= 'a') && (ch <= 'f'))
return ch - 'a' + 10;
return -1;
}




\
 
 \ /
  Last update: 2010-05-01 04:59    [W:0.445 / U:0.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site