Re: [PATCH] kstrtox: reuse functions from ctype.h

From: Alexey Dobriyan
Date: Fri Apr 15 2011 - 16:51:59 EST


On Thu, Apr 14, 2011 at 04:30:17PM +0200, Michal Nazarewicz wrote:
> On Thu, 14 Apr 2011 16:06:34 +0200, Alexey Dobriyan <adobriyan@xxxxxxxxx>
> wrote:

> >> @@ -47,8 +42,8 @@ static int _kstrtoull(const char *s, unsigned int
> >> base, unsigned long long *res)
> >>
> >> if ('0' <= *s && *s <= '9')
> >> val = *s - '0';
> >> - else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f')
> >> - val = _tolower(*s) - 'a' + 10;
> >> + else if (isxdigit(*s))
> >
> > [0-9] are isxdigit() as well, so the code sort of logically duplicate.
>
> Yes, so? ;)
>
> I think isxdigit(*s) looks nicer than â'a' <= _tolower(*s) &&
> _tolower(*s) <= 'f'â.

If you write isxdigit(*s) you have to write some other expression for
"val = " to be nicer.

The point it's doesn't matter, compiler will optimize all those _tolower().
--
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/