Converting strings to integers
As of 2.6.39, there is a new set of string-to-integer converters which is expected to be used in preference to all others.
- Unsigned conversions can be done with any of kstrtoull(),
kstrtoul(), kstrtouint(), kstrtou64(),
kstrtou32(), kstrtou16(), or kstrtou8().
- Conversions to signed integers can be done with kstrtoll(), kstrtol(), kstrtoint(), kstrtos64(), kstrtos32(), kstrtos16(), or kstrtos8().
All of these functions are marked __must_check, so callers are
expected to check to ensure that the conversion happened successfully. The
older functions are marked deprecated, and will eventually be removed.
These new kstrto*() functions are now the Official Best Way To
Convert Strings, so developers need wonder no longer.
| Index entries for this article | |
|---|---|
| Kernel | String processing |