git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 4/4] list-objects-filter: convert filter_spec to a strbuf

From
Jeff King <peff@peff.net>
Date
Sep 19, 2022, 19:05 UTC
Message-ID
<Yyi9lkns3OgjiLl0@coredump.intra.peff.net>
In-Reply-To
<2c6fca96-6b7b-b4c4-526c-2497422d8b8f@github.com>
On Mon, Sep 19, 2022 at 01:50:32PM -0400, Derrick Stolee wrote:
Show 16 quoted lines
> 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
Previous: Derrick StoleeNext: Jeff King
Message 9 of 11 in “list-objects-filter cleanups”
  1. 0/4 list-objects-filter cleanupsJeff King, Sep 11, 2022
  2. 1/4 list-objects-filter: don't memset after releasing filter structJeff King, Sep 11, 2022
  3. Junio C HamanoSep 12, 2022
  4. 2/4 list-objects-filter: handle null default filter specJeff King, Sep 11, 2022
  5. Junio C HamanoSep 12, 2022
  6. 3/4 list-objects-filter: add and use initializersJeff King, Sep 11, 2022
  7. 4/4 list-objects-filter: convert filter_spec to a strbufJeff King, Sep 11, 2022
  8. Derrick StoleeSep 19, 2022
  9. Jeff KingSep 19, 2022
  10. Jeff KingSep 11, 2022
  11. Derrick StoleeSep 19, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.