[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 8 Aug 2022 10:58:39 -0400
From: Kent Overstreet <kent.overstreet@...il.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>,
"Matthew Wilcox (Oracle)" <willy@...radead.org>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Petr Mladek <pmladek@...e.com>,
Andy Shevchenko <andy@...nel.org>
Subject: Re: [PATCH v5 02/32] lib/string_helpers: Convert string_escape_mem()
to printbuf
On 8/8/22 08:03, Andy Shevchenko wrote:
> 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?
I generally try to keep my #includes alphabetized, missed this :)
>
> ...
>
>> @@ -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.
Fixed
> ...
>
>> 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?
Yep, done
>> 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 (?)
See below
>
>> + * 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
Yeah I'm actually not changing the function comment for
string_escape_mem(), that's just git getting confused since I reused
most of it for prt_escaped_mem(). I'll leave any fixups for that for you
if that's ok - the docs look clear enough to me.
Cheers
Powered by blists - more mailing lists