/* Internal, do not use. */ int __must_check _kstrtoul(constchar *s, unsignedint base, unsignedlong *res); int __must_check _kstrtol(constchar *s, unsignedint base, long *res);
int __must_check kstrtoull(constchar *s, unsignedint base, unsignedlonglong *res); int __must_check kstrtoll(constchar *s, unsignedint base, longlong *res);
/** * kstrtoul - convert a string to an unsigned long * @s: The start of the string. The string must be null-terminated, and may also * include a single newline before its terminating null. The first character * may also be a plus sign, but not a minus sign. * @base: The number base to use. The maximum supported base is 16. If base is * given as 0, then the base of the string is automatically detected with the * conventional semantics - If it begins with 0x the number will be parsed as a * hexadecimal (case insensitive), if it otherwise begins with 0, it will be * parsed as an octal number. Otherwise it will be parsed as a decimal. * @res: Where to write the result of the conversion on success. * * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. * Preferred over simple_strtoul(). Return code must be checked.
*/ staticinlineint __must_check kstrtoul(constchar *s, unsignedint base, unsignedlong *res)
{ /* * We want to shortcut function call, but * __builtin_types_compatible_p(unsigned long, unsigned long long) = 0.
*/ if (sizeof(unsignedlong) == sizeof(unsignedlonglong) &&
__alignof__(unsignedlong) == __alignof__(unsignedlonglong)) return kstrtoull(s, base, (unsignedlonglong *)res); else return _kstrtoul(s, base, res);
}
/** * kstrtol - convert a string to a long * @s: The start of the string. The string must be null-terminated, and may also * include a single newline before its terminating null. The first character * may also be a plus sign or a minus sign. * @base: The number base to use. The maximum supported base is 16. If base is * given as 0, then the base of the string is automatically detected with the * conventional semantics - If it begins with 0x the number will be parsed as a * hexadecimal (case insensitive), if it otherwise begins with 0, it will be * parsed as an octal number. Otherwise it will be parsed as a decimal. * @res: Where to write the result of the conversion on success. * * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. * Preferred over simple_strtol(). Return code must be checked.
*/ staticinlineint __must_check kstrtol(constchar *s, unsignedint base, long *res)
{ /* * We want to shortcut function call, but * __builtin_types_compatible_p(long, long long) = 0.
*/ if (sizeof(long) == sizeof(longlong) &&
__alignof__(long) == __alignof__(longlong)) return kstrtoll(s, base, (longlong *)res); else return _kstrtol(s, base, res);
}
int __must_check kstrtouint(constchar *s, unsignedint base, unsignedint *res); int __must_check kstrtoint(constchar *s, unsignedint base, int *res);
/* * Use kstrto<foo> instead. * * NOTE: simple_strto<foo> does not check for the range overflow and, * depending on the input, may give interesting results. * * Use these functions if and only if you cannot use kstrto<foo>, because * the conversion ends on the first non-digit character, which may be far * beyond the supported range. It might be useful to parse the strings like * 10x50 or 12:21 without altering original string or temporary buffer in use. * Keep in mind above caveat.
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.