Re: [PATCH] Add parse_integer() (replacement for simple_strto*())

From: Alexey Dobriyan
Date: Sat Apr 11 2015 - 11:37:30 EST


On Thu, Apr 09, 2015 at 01:02:47PM -0700, Andrew Morton wrote:
> On Thu, 9 Apr 2015 18:26:14 +0300 Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:
>
> > kstrto*() and kstrto*_from_user() family of functions were added
> > help with parsing one integer written as string to proc/sysfs/debugfs
> > files and pass it elsewhere. But they have a limitation: string passed
> > must end with \0 or \n\0. There are enough places where kstrto*()
> > functions can't be used because of this limitation. Trivial example:
> > parse "%u.%u".
> >
> > ...
> >
> > include/linux/kernel.h | 72 +++++++++++++++++++
> > lib/Makefile | 1
> > lib/kstrtox.c | 27 +------
> > lib/parse-integer.c | 180 +++++++++++++++++++++++++++++++++++++++++++++++++
> > 4 files changed, 257 insertions(+), 23 deletions(-)
>
> That's a lot of code for something which is almost the same as
> kstrtofoo().
>
> Can we hack up _kstrtoull() to optionally provide the new behaviour?
> We could use the top bit of `base' to select the behaviour.

Hmm, OK. I did it the opposite way, though.
parse_integer() becomes core interface, kstrto*() become wrappers.

Alexey
--
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/