kstrto*: converting strings to integers done (hopefully) right
authorAlexey Dobriyan <adobriyan@gmail.com>
Tue, 22 Mar 2011 23:34:40 +0000 (16:34 -0700)
committerBrad Figg <brad.figg@canonical.com>
Wed, 27 Apr 2011 18:42:07 +0000 (11:42 -0700)
commit15c18dbf762575b7e99c57da6ea168782ab45e4c
tree7036f6dca78ad3a1e14eb3906ed732eed9825781
parent0f59231cc65c6ad17e6ce4c347a89e36b7cbf480
kstrto*: converting strings to integers done (hopefully) right

BugLink: http://bugs.launchpad.net/bugs/769042

commit 33ee3b2e2eb9b4b6c64dcf9ed66e2ac3124e748c upstream.

1. simple_strto*() do not contain overflow checks and crufty,
   libc way to indicate failure.
2. strict_strto*() also do not have overflow checks but the name and
   comments pretend they do.
3. Both families have only "long long" and "long" variants,
   but users want strtou8()
4. Both "simple" and "strict" prefixes are wrong:
   Simple doesn't exactly say what's so simple, strict should not exist
   because conversion should be strict by default.

The solution is to use "k" prefix and add convertors for more types.
Enter
kstrtoull()
kstrtoll()
kstrtoul()
kstrtol()
kstrtouint()
kstrtoint()

kstrtou64()
kstrtos64()
kstrtou32()
kstrtos32()
kstrtou16()
kstrtos16()
kstrtou8()
kstrtos8()

Include runtime testsuite (somewhat incomplete) as well.

strict_strto*() become deprecated, stubbed to kstrto*() and
eventually will be removed altogether.

Use kstrto*() in code today!

Note: on some archs _kstrtoul() and _kstrtol() are left in tree, even if
      they'll be unused at runtime. This is temporarily solution,
      because I don't want to hardcode list of archs where these
      functions aren't needed. Current solution with sizeof() and
      __alignof__ at least always works.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>
drivers/video/via/viafbdev.h
include/linux/kernel.h
lib/Kconfig.debug
lib/Makefile
lib/kstrtox.c [new file with mode: 0644]
lib/test-kstrtox.c [new file with mode: 0644]
lib/vsprintf.c
scripts/checkpatch.pl