History

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.

Alexey Dobriyan committed 15 years ago

Commit 33ee3b21 parent 8a5700c8 files · +1039 −150Browse files

Showing the changes to scripts/checkpatch.pl (1 of 8 files). Show all

Unified · Split

scripts/checkpatch.pl+2−2
@@ -2804,9 +2804,9 @@ sub process { · 2803 unmodified lines
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 please2811# check for __initcall(), use device_initcall() explicitly please
2812 if ($line =~ /^.\s*__initcall\s*\(/) {2812 if ($line =~ /^.\s*__initcall\s*\(/) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t