public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kent Overstreet <kent.overstreet@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Petr Mladek <pmladek@suse.com>, Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH v5 02/32] lib/string_helpers: Convert string_escape_mem() to printbuf
Date: Mon, 8 Aug 2022 10:58:39 -0400	[thread overview]
Message-ID: <61bbfb03-3493-5e1e-da00-fee555393d4a@gmail.com> (raw)
In-Reply-To: <CAHp75Vcua1dCZQ-ZvcAxkorfXzr6rmJO6=wVYLoomdMzLXDRtw@mail.gmail.com>

On 8/8/22 08:03, Andy Shevchenko wrote:
> On Mon, Aug 8, 2022 at 4:41 AM Matthew Wilcox (Oracle)
> <willy@infradead.org> wrote:
>>
>> From: Kent Overstreet <kent.overstreet@gmail.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

  reply	other threads:[~2022-08-08 14:59 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08  2:40 [PATCH v5 00/32] Printbufs Matthew Wilcox (Oracle)
2022-08-08  2:40 ` [PATCH v5 01/32] lib/printbuf: New data structure for printing strings Matthew Wilcox (Oracle)
2022-08-08  2:40 ` [PATCH v5 02/32] lib/string_helpers: Convert string_escape_mem() to printbuf Matthew Wilcox (Oracle)
2022-08-08 12:03   ` Andy Shevchenko
2022-08-08 14:58     ` Kent Overstreet [this message]
2022-08-08  2:40 ` [PATCH v5 03/32] vsprintf: Convert " Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 04/32] lib/hexdump: " Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 05/32] lib/string_helpers: string_get_size() now returns characters wrote Matthew Wilcox (Oracle)
2022-08-08 13:08   ` Andy Shevchenko
2022-08-08  2:41 ` [PATCH v5 06/32] lib/printbuf: Heap allocation Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 07/32] lib/printbuf: Tabstops, indenting Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 08/32] lib/printbuf: Unit specifiers Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 09/32] vsprintf: Improve number() Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 10/32] vsprintf: prt_u64_minwidth(), prt_u64() Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 11/32] test_printf: Drop requirement that sprintf not write past nul Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 12/32] vsprintf: Start consolidating printf_spec handling Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 13/32] vsprintf: Refactor resource_string() Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 14/32] vsprintf: Refactor fourcc_string() Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 15/32] vsprintf: Refactor ip_addr_string() Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 16/32] vsprintf: Refactor mac_address_string() Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 17/32] vsprintf: time_and_date() no longer takes printf_spec Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 18/32] vsprintf: flags_string() " Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 19/32] vsprintf: Refactor device_node_string, fwnode_string Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 20/32] vsprintf: Refactor hex_string, bitmap_string_list, bitmap_string Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 21/32] Input/joystick/analog: Convert from seq_buf -> printbuf Matthew Wilcox (Oracle)
2022-08-11  1:37   ` Dmitry Torokhov
2022-08-08  2:41 ` [PATCH v5 22/32] mm/memcontrol.c: Convert to printbuf Matthew Wilcox (Oracle)
2022-08-08  9:48   ` Michal Hocko
2022-08-08 12:48     ` Michal Hocko
2022-08-08  2:41 ` [PATCH v5 23/32] clk: tegra: bpmp: " Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 24/32] tools/testing/nvdimm: " Matthew Wilcox (Oracle)
2022-08-08 18:30   ` Dan Williams
2022-08-08 18:33     ` Kent Overstreet
2022-08-08  2:41 ` [PATCH v5 25/32] powerpc: " Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 26/32] x86/resctrl: " Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 27/32] PCI/P2PDMA: " Matthew Wilcox (Oracle)
2022-08-08 17:51   ` Bjorn Helgaas
2022-08-08 18:42     ` Kent Overstreet
2022-08-09  2:07       ` Bjorn Helgaas
2022-08-09  8:00         ` Christoph Hellwig
2022-08-08  2:41 ` [PATCH v5 28/32] tracing: trace_events_synth: " Matthew Wilcox (Oracle)
2022-08-08  2:41 ` [PATCH v5 29/32] d_path: prt_path() Matthew Wilcox (Oracle)
2022-08-08  4:17   ` Al Viro
2022-08-08  4:27     ` Kent Overstreet
2022-08-08  2:41 ` [PATCH v5 30/32] ACPI/APEI: Add missing include Matthew Wilcox (Oracle)
2022-08-08 14:09   ` Rafael J. Wysocki
2022-08-08  2:41 ` [PATCH v5 31/32] tracing: Convert to printbuf Matthew Wilcox (Oracle)
2022-08-08  2:51   ` Steven Rostedt
2022-08-08  3:32     ` Kent Overstreet
2022-08-08 13:37       ` Steven Rostedt
2022-08-08 15:15         ` Kent Overstreet
2022-08-08 15:25           ` Steven Rostedt
2022-08-08  2:41 ` [PATCH v5 32/32] Delete seq_buf Matthew Wilcox (Oracle)
2022-09-23  7:10 ` [PATCH v5 00/32] Printbufs Petr Mladek
2022-09-24  1:39   ` Kent Overstreet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61bbfb03-3493-5e1e-da00-fee555393d4a@gmail.com \
    --to=kent.overstreet@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox