From: Jeff King <peff@peff.net>
To: Derrick Stolee <derrickstolee@github.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/4] list-objects-filter: convert filter_spec to a strbuf
Date: Mon, 19 Sep 2022 14:05:58 -0500 [thread overview]
Message-ID: <Yyi9lkns3OgjiLl0@coredump.intra.peff.net> (raw)
In-Reply-To: <2c6fca96-6b7b-b4c4-526c-2497422d8b8f@github.com>
On Mon, Sep 19, 2022 at 01:50:32PM -0400, Derrick Stolee wrote:
> On 9/11/2022 1:03 AM, Jeff King wrote:
> > - if (!filter_options->filter_spec.strdup_strings)
> > + if (!filter_options->filter_spec.buf)
> > BUG("filter_options not properly initialized");
>
> I couldn't figure out why this would work until I dug into
> STRBUF_INIT and found this:
>
> /*
> * Used as the default ->buf value, so that people can always assume
> * buf is non NULL and ->buf is NUL terminated even for a freshly
> * initialized strbuf.
> */
> char strbuf_slopbuf[1];
>
> So, this makes sense now.
Yeah. It's a little intimate with the strbuf implementation, but I think
that's OK given the scope of things here. Ironically, if "buf" could be
NULL, then we'd actually be OK with the original zero-initialization. :)
-Peff
next prev parent reply other threads:[~2022-09-19 19:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-11 4:57 [PATCH 0/4] list-objects-filter cleanups Jeff King
2022-09-11 4:58 ` [PATCH 1/4] list-objects-filter: don't memset after releasing filter struct Jeff King
2022-09-12 15:40 ` Junio C Hamano
2022-09-11 5:00 ` [PATCH 2/4] list-objects-filter: handle null default filter spec Jeff King
2022-09-12 16:56 ` Junio C Hamano
2022-09-11 5:03 ` [PATCH 3/4] list-objects-filter: add and use initializers Jeff King
2022-09-11 5:03 ` [PATCH 4/4] list-objects-filter: convert filter_spec to a strbuf Jeff King
2022-09-19 17:50 ` Derrick Stolee
2022-09-19 19:05 ` Jeff King [this message]
2022-09-11 5:07 ` [PATCH 0/4] list-objects-filter cleanups Jeff King
2022-09-19 17:51 ` Derrick Stolee
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=Yyi9lkns3OgjiLl0@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).