Subject: Re: [PATCH] cocci: strbuf.buf is never NULL

From: Derrick Stolee <[email-masked]>
Date: Fri, 20 Mar 2026 12:31:07 -0400

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.

> +// 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