[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 8 Aug 2022 14:03:02 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: "Matthew Wilcox (Oracle)" <willy@...radead.org>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Petr Mladek <pmladek@...e.com>,
Kent Overstreet <kent.overstreet@...il.com>,
Andy Shevchenko <andy@...nel.org>
Subject: Re: [PATCH v5 02/32] lib/string_helpers: Convert string_escape_mem()
to printbuf
On Mon, Aug 8, 2022 at 4:41 AM Matthew Wilcox (Oracle)
<willy@...radead.org> wrote:
>
> From: Kent Overstreet <kent.overstreet@...il.com>
>
> 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.
...
> struct device;
> struct file;
> struct task_struct;
> +struct printbuf;
Keep it ordered?
...
> @@ -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)
> {
Stray change.
...
> if (!(is_append || in_dict) && is_dict &&
> - escape_passthrough(c, &p, end))
> + escape_passthrough(out, c))
That (a bit strange) indentation is on purpose. Can we keep it?
> continue;
...
Not sure if the below was in the original text, but maybe it makes
sense to amend.
> + * Description:
> + * The process of escaping byte buffer includes several parts. They are applied
a byte in the buffer (?)
> + * in the following sequence.
> + *
> + * 1. The character is not matched to the one from @only string and thus
> + * must go as-is to the output.
> + * 2. The character is matched to the printable and ASCII classes, if asked,
> + * and in case of match it passes through to the output.
> + * 3. The character is matched to the printable or ASCII class, if asked,
> + * and in case of match it passes through to the output.
> + * 4. The character is checked if it falls into the class given by @flags.
> + * %ESCAPE_OCTAL and %ESCAPE_HEX are going last since they cover any
> + * character. Note that they actually can't go together, otherwise
> + * %ESCAPE_HEX will be ignored.
> + *
> + * Caller must provide valid source and destination pointers. Be aware that
> + * destination buffer will not be NULL-terminated, thus caller have to append
the caller has
> + * it if needs. The supported flags are::
if needed.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists