Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kernel.h: update comment about simple_strto<foo>() functions

There were discussions in the past about use cases for
simple_strto<foo>() functions and, in some rare cases, they have a
benefit over kstrto<foo>() ones.

Update a comment to reduce confusion about special use cases.

Link: http://lkml.kernel.org/r/20190801192904.41087-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Suggested-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Mans Rullgard <mans@mansr.com>
Cc: Petr Mladek <pmladek@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Andy Shevchenko and committed by
Linus Torvalds
885e68e8 2f5bd343

+14 -5
+14 -5
include/linux/kernel.h
··· 348 348 * @res: Where to write the result of the conversion on success. 349 349 * 350 350 * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. 351 - * Used as a replacement for the obsolete simple_strtoull. Return code must 352 - * be checked. 351 + * Used as a replacement for the simple_strtoull. Return code must be checked. 353 352 */ 354 353 static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res) 355 354 { ··· 376 377 * @res: Where to write the result of the conversion on success. 377 378 * 378 379 * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. 379 - * Used as a replacement for the obsolete simple_strtoull. Return code must 380 - * be checked. 380 + * Used as a replacement for the simple_strtoull. Return code must be checked. 381 381 */ 382 382 static inline int __must_check kstrtol(const char *s, unsigned int base, long *res) 383 383 { ··· 452 454 return kstrtoint_from_user(s, count, base, res); 453 455 } 454 456 455 - /* Obsolete, do not use. Use kstrto<foo> instead */ 457 + /* 458 + * Use kstrto<foo> instead. 459 + * 460 + * NOTE: simple_strto<foo> does not check for the range overflow and, 461 + * depending on the input, may give interesting results. 462 + * 463 + * Use these functions if and only if you cannot use kstrto<foo>, because 464 + * the conversion ends on the first non-digit character, which may be far 465 + * beyond the supported range. It might be useful to parse the strings like 466 + * 10x50 or 12:21 without altering original string or temporary buffer in use. 467 + * Keep in mind above caveat. 468 + */ 456 469 457 470 extern unsigned long simple_strtoul(const char *,char **,unsigned int); 458 471 extern long simple_strtol(const char *,char **,unsigned int);