From: Derrick Stolee <stolee@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] cocci: strbuf.buf is never NULL
Date: Fri, 20 Mar 2026 12:31:07 -0400 [thread overview]
Message-ID: <228bfbe3-af2d-49b7-984e-cae7b1b8af28@gmail.com> (raw)
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.
> +// 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
prev parent reply other threads:[~2026-03-20 16:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 22:39 [PATCH] cocci: strbuf.buf is never NULL Junio C Hamano
2026-03-20 16:31 ` Derrick Stolee [this message]
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=228bfbe3-af2d-49b7-984e-cae7b1b8af28@gmail.com \
--to=stolee@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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