summaryrefslogtreecommitdiff
path: root/include/linux/string_helpers.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-05-31 18:42:12 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-06-04 15:10:02 -0400
commite1948ae9f617eebb48779174663b49f14f8b62d2 (patch)
tree62b9e852e7a7a32ae263c0be563eaed872c7b000 /include/linux/string_helpers.h
parentb5903bb897ac85a0b548e3dbcab3697f4ce9cd5f (diff)
lib/string_helpers: Convert string_escape_mem() to printbuf
Like the upcoming vsprintf.c conversion, this converts string_escape_mem to prt_escaped_string(), which uses and outputs to a printbuf, and makes string_escape_mem() a smaller wrapper to support existing users. The new printbuf helpers greatly simplify the code. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'include/linux/string_helpers.h')
-rw-r--r--include/linux/string_helpers.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index 4d72258d42fd..67de398944e8 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -10,6 +10,7 @@
struct device;
struct file;
struct task_struct;
+struct printbuf;
/* Descriptions of the types of units to
* print in */
@@ -62,6 +63,8 @@ static inline int string_unescape_any_inplace(char *buf)
#define ESCAPE_ALL_MASK GENMASK(8, 0)
+void prt_escaped_string(struct printbuf *out, const char *src, size_t isz,
+ unsigned int flags, const char *only);
int string_escape_mem(const char *src, size_t isz, char *dst, size_t osz,
unsigned int flags, const char *only);
@@ -71,6 +74,7 @@ static inline int string_escape_mem_any_np(const char *src, size_t isz,
return string_escape_mem(src, isz, dst, osz, ESCAPE_ANY_NP, only);
}
+
static inline int string_escape_str(const char *src, char *dst, size_t sz,
unsigned int flags, const char *only)
{