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

Re: [PATCH 4/3] use string_list initializer consistently

From
Duy Nguyen <pclouds@gmail.com>
Date
Jun 13, 2016, 11:31 UTC
Message-ID
<CACsJy8CoOJKLUQXPKx_KvHvwbUdOfyBKu_-v5F2U7ccrmCcewA@mail.gmail.com>
In-Reply-To
<20160613100420.GA16229@sigill.intra.peff.net>
On Mon, Jun 13, 2016 at 5:04 PM, Jeff King <peff@peff.net> wrote:
Show 18 quoted lines
> -- >8 --
> Subject: use string_list initializer consistently
>
> There are two types of string_lists: those that own the
> string memory, and those that don't. You can tell the
> difference by the strdup_strings flag, and one should use
> either STRING_LIST_INIT_DUP, or STRING_LIST_INIT_NODUP as an
> initializer.
>
> Historically, the normal all-zeros initialization has
> corresponded to the NODUP case. Many sites use no
> initializer at all, and that works as a shorthand for that
> case. But for a reader of the code, it can be hard to
> remember which is which. Let's be more explicit and actually
> have each site declare which type it means to use.
>
> This is a fairly mechanical conversion; I assumed each site
> was correct as-is, and just switched them all to NODUP.

Looking good. If we still want to reduce noise level down (by a tiny bit), we could remove _INIT because I think it's obvious from

struct string_list var = STRING_LIST_NODUP;

that's it's initialization (I wish we could write "auto var = STRING_LIST_NODUP;")

-- 
Duy
Previous: Jeff KingNext: Jeff King
Message 14 of 15 in “parse-options-cb.c: use string_list_append_nodup in OPT_STRING_LIST()”
  1. parse-options-cb.c: use string_list_append_nodup in OPT_STRING_LIST()Nguyễn Thái Ngọc Duy, Jun 10, 2016
  2. Jeff KingJun 12, 2016
  3. Duy NguyenJun 13, 2016
  4. 0/3 fix parse-opt string_list leaksJeff King, Jun 13, 2016
  5. 1/3 parse_opt_string_list: stop allocating new stringsJeff King, Jun 13, 2016
  6. 2/3 interpret-trailers: don't duplicate option stringsJeff King, Jun 13, 2016
  7. 3/3 blame,shortlog: don't make local option variables staticJeff King, Jun 13, 2016
  8. Eric SunshineJun 14, 2016
  9. Jeff KingJun 14, 2016
  10. blame: drop strdup of string literalJeff King, Aug 2, 2016
  11. Eric SunshineAug 3, 2016
  12. Duy NguyenJun 13, 2016
  13. 4/3 use string_list initializer consistentlyJeff King, Jun 13, 2016
  14. Duy NguyenJun 13, 2016
  15. Jeff KingJun 13, 2016

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.