const-correctness in grep.c
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest5 patches 26 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | grep: stop modifying buffer in strip_timestampgrep.c | +3 | 10 replies | |
| 2/5 | grep: stop modifying buffer in show_line()grep.c | +0 | 3 replies | |
| 3/5 | grep: stop modifying buffer in grep_source_1()grep.c | +1 | 0 replies | |
| 4/5 | grep: mark "haystack" buffers as constgrep.c | +35 | 2 replies | |
| 5/5 | grep: store grep_source buffer as constgrep.c grep.h | +8 | 0 replies |
Reviews trailers per patch
None of the 5 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Taylor Blau |
|---|---|
| Series | R-b |
| 1/5 | |
| 2/5 | |
| 3/5 | |
| 4/5 | |
| 5/5 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/5] const-correctness in grep.c
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.
The first three patches are a bit repetitive, but I broke them up individually because they're the high-risk part. I.e., if my assumptions about needing the NUL are wrong, it could introduce a bug. But based on my reading of the code, plus running the test suite with ASan/UBSan, I feel reasonably confident.
The last two are the bigger cleanups, but should obviously avoid any behavior changes.
[1/5]: grep: stop modifying buffer in strip_timestamp [2/5]: grep: stop modifying buffer in show_line() [3/5]: grep: stop modifying buffer in grep_source_1() [4/5]: grep: mark "haystack" buffers as const [5/5]: grep: store grep_source buffer as const
grep.c | 87 +++++++++++++++++++++++++++++----------------------------- grep.h | 4 +-- 2 files changed, 45 insertions(+), 46 deletions(-)
-Peff