Re: [PATCH 0/5] const-correctness in grep.c
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Sep 21, 2021, 04:30 UTC
- Message-ID
- <YUlf8HyBWC7aDF8n@nand.local>
- In-Reply-To
- <YUlVZk1xXulAqdef@coredump.intra.peff.net>
On Mon, Sep 20, 2021 at 11:45:42PM -0400, Jeff King wrote:
Show 6 quoted lines
> While discussing [1], I noticed that the grep code mostly takes > non-const buffers, even though it is conceptually a read-only operation > to search in them. The culprit is a handful of spots that temporarily > tie off NUL-terminated strings by overwriting a byte of the buffer and > then restoring it. But I think we no longer need to do so these days, > now that we have a regexec_buf() that can take a ptr/size pair.
This all looks very reasonable to me. I appreciated the way you broke up each spot that unnecessarily modified a buffer into its own patch with its own explanation.
I looked through each of the three spots you mentioned with a close eye and concurred with your reasoning. (To the extent it was possible, I tried to ignore most of your commentary until I had generated my own understanding while searching through my copy of grep.c).
Thanks for an enjoyable set of patches to read.
Reviewed-by: Taylor Blau <me@ttaylorr.com>
> [1] https://lore.kernel.org/git/YUk3zwuse56v76ze@coredump.intra.peff.net/
Thanks, Taylor