Re: [PATCH 01/10] lib: introduce common method to convert hexdigits

From: Joe Perches
Date: Fri Apr 30 2010 - 22:56:13 EST


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;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/