Re: [PATCH] cocci: strbuf.buf is never NULL
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Mar 20, 2026, 16:31 UTC
- Message-ID
- <228bfbe3-af2d-49b7-984e-cae7b1b8af28@gmail.com>
- In-Reply-To
- <xmqq4imbigvt.fsf@gitster.g>
On 3/19/2026 6:39 PM, Junio C Hamano wrote:
> We recently noticed one old code from 19 years ago protecting > against an ancient strbuf convention that the .buf member can be > NULL for an empty strbuf. As that is no longer the case in the > modern codebase, let's catch such a construct.
Show 6 quoted lines
> +// In modern codebase, .buf member of an empty strbuf is not NULL. > +@@ > +struct strbuf SB; > +@@ > +- SB.buf ? SB.buf : "" > ++ SB.buf
LGTM. I like to see these structural patterns encoded as rules.
Thanks, -Stolee