linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 1/2] kernel.h: Update comment about simple_strto<foo>() functions
@ 2019-08-01 19:29 Andy Shevchenko
  2019-08-01 19:29 ` [PATCH v4 2/2] auxdisplay: charlcd: Deduplicate simple_strtoul() Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andy Shevchenko @ 2019-08-01 19:29 UTC (permalink / raw)
  To: Miguel Ojeda Sandonis, linux-kernel, Geert Uytterhoeven,
	Mans Rullgard, Andrew Morton, Petr Mladek
  Cc: Andy Shevchenko

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.

Suggested-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v4: modify comment to be more precise (Petr)
 include/linux/kernel.h | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4fa360a13c1e..60a9529ee740 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -334,8 +334,7 @@ int __must_check kstrtoll(const char *s, unsigned int base, long long *res);
  * @res: Where to write the result of the conversion on success.
  *
  * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error.
- * Used as a replacement for the obsolete simple_strtoull. Return code must
- * be checked.
+ * Used as a replacement for the simple_strtoull. Return code must be checked.
 */
 static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res)
 {
@@ -363,8 +362,7 @@ static inline int __must_check kstrtoul(const char *s, unsigned int base, unsign
  * @res: Where to write the result of the conversion on success.
  *
  * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error.
- * Used as a replacement for the obsolete simple_strtoull. Return code must
- * be checked.
+ * Used as a replacement for the simple_strtoull. Return code must be checked.
  */
 static inline int __must_check kstrtol(const char *s, unsigned int base, long *res)
 {
@@ -440,7 +438,18 @@ static inline int __must_check kstrtos32_from_user(const char __user *s, size_t
 	return kstrtoint_from_user(s, count, base, res);
 }
 
-/* Obsolete, do not use.  Use kstrto<foo> instead */
+/*
+ * 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.
+ */
 
 extern unsigned long simple_strtoul(const char *,char **,unsigned int);
 extern long simple_strtol(const char *,char **,unsigned int);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-11-08 12:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-01 19:29 [PATCH v4 1/2] kernel.h: Update comment about simple_strto<foo>() functions Andy Shevchenko
2019-08-01 19:29 ` [PATCH v4 2/2] auxdisplay: charlcd: Deduplicate simple_strtoul() Andy Shevchenko
2019-08-01 19:50 ` [PATCH v4 1/2] kernel.h: Update comment about simple_strto<foo>() functions Miguel Ojeda
2019-08-26 13:43   ` Andy Shevchenko
2019-11-08 12:59     ` Andy Shevchenko
2019-08-01 19:58 ` Joe Perches
2019-08-02  7:55   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).