diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2011-03-22 19:34:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-22 20:44:14 -0400 |
commit | 33ee3b2e2eb9b4b6c64dcf9ed66e2ac3124e748c (patch) | |
tree | 25d70c021189efa0bcbdf4e84b3ca97a6c147246 /scripts/checkpatch.pl | |
parent | 8a5700cd6754a3c88d2ea2f1d7a56f671987fc25 (diff) |
kstrto*: converting strings to integers done (hopefully) right
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>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-x | scripts/checkpatch.pl | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 58848e3e392c..dfd9b310a1cc 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -2804,9 +2804,9 @@ sub process { | |||
2804 | WARN("consider using a completion\n" . $herecurr); | 2804 | WARN("consider using a completion\n" . $herecurr); |
2805 | 2805 | ||
2806 | } | 2806 | } |
2807 | # recommend strict_strto* over simple_strto* | 2807 | # recommend kstrto* over simple_strto* |
2808 | if ($line =~ /\bsimple_(strto.*?)\s*\(/) { | 2808 | if ($line =~ /\bsimple_(strto.*?)\s*\(/) { |
2809 | WARN("consider using strict_$1 in preference to simple_$1\n" . $herecurr); | 2809 | WARN("consider using kstrto* in preference to simple_$1\n" . $herecurr); |
2810 | } | 2810 | } |
2811 | # check for __initcall(), use device_initcall() explicitly please | 2811 | # check for __initcall(), use device_initcall() explicitly please |
2812 | if ($line =~ /^.\s*__initcall\s*\(/) { | 2812 | if ($line =~ /^.\s*__initcall\s*\(/) { |