From e1948ae9f617eebb48779174663b49f14f8b62d2 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Tue, 31 May 2022 18:42:12 -0400 Subject: 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 --- include/linux/string_helpers.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/linux/string_helpers.h') 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) { -- cgit v1.2.3