summaryrefslogtreecommitdiffstats
path: root/include/linux/string_helpers.h
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2023-02-08 15:31:51 +0200
committerJakub Kicinski <kuba@kernel.org>2023-02-09 22:30:24 -0800
commitf1db99c07b4f0a9edc45f3498d4d13d13a41836a (patch)
tree598bb0442756c5e932bf7e9d80445e9818b98be5 /include/linux/string_helpers.h
parenta136391ae4216a5713f9527c8a05e9364f059a31 (diff)
downloadlinux-stable-f1db99c07b4f0a9edc45f3498d4d13d13a41836a.tar.gz
linux-stable-f1db99c07b4f0a9edc45f3498d4d13d13a41836a.tar.bz2
linux-stable-f1db99c07b4f0a9edc45f3498d4d13d13a41836a.zip
string_helpers: Move string_is_valid() to the header
Move string_is_valid() to the header for wider use. While at it, rename to string_is_terminated() to be precise about its semantics. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Link: https://lore.kernel.org/r/20230208133153.22528-1-andriy.shevchenko@linux.intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/linux/string_helpers.h')
-rw-r--r--include/linux/string_helpers.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index 8530c7328269..fae6beaaa217 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -11,6 +11,11 @@ struct device;
struct file;
struct task_struct;
+static inline bool string_is_terminated(const char *s, int len)
+{
+ return memchr(s, '\0', len) ? true : false;
+}
+
/* Descriptions of the types of units to
* print in */
enum string_size_units {