From: Alexey Dobriyan <adobriyan@gmail.com>
To: Michal Nazarewicz <mina86@mina86.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kstrtox: reuse functions from ctype.h
Date: Thu, 14 Apr 2011 17:06:34 +0300 [thread overview]
Message-ID: <BANLkTikk3Zof1Go8xLBeq2qyxGo6AFuv1g@mail.gmail.com> (raw)
In-Reply-To: <b266439c1f03640c677f911cb82f4d0e131d2e7d.1302785632.git.mina86@mina86.com>
On Thu, Apr 14, 2011 at 4:34 PM, Michal Nazarewicz <mina86@mina86.com> wrote:
> kstrto*() family of functions uses open coded test
> for a hexadecimal digit and
Yes, so?
> own implementation of tolower() function.
No!
It's special cased for this very usage, because the rest of ASCII is
of no concern.
It doesn't claim tolower() semantics.
> - if (_tolower(s[1]) == 'x' && isxdigit(s[2]))
> + if (tolower(s[1]) == 'x' && isxdigit(s[2]))
> base = 16;
> else
> base = 8;
> } else
> base = 10;
> }
> - if (base == 16 && s[0] == '0' && _tolower(s[1]) == 'x')
> + if (base == 16 && s[0] == '0' && tolower(s[1]) == 'x')
> s += 2;
>
> acc = 0;
> @@ -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.
> + val = tolower(*s) - 'a' + 10;
next prev parent reply other threads:[~2011-04-14 14:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-14 13:34 [PATCH] kstrtox: reuse functions from ctype.h Michal Nazarewicz
2011-04-14 14:06 ` Alexey Dobriyan [this message]
2011-04-14 14:30 ` Michal Nazarewicz
2011-04-15 20:51 ` Alexey Dobriyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BANLkTikk3Zof1Go8xLBeq2qyxGo6AFuv1g@mail.gmail.com \
--to=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mina86@mina86.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).