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

Re: [PATCH 0/5] *.[ch]: don't duplicate *_init() and *_INIT logic

From
Jeff King <peff@peff.net>
Date
Jul 1, 2021, 16:13 UTC
Message-ID
<YN3pmS8q3dA3Gnd+@coredump.intra.peff.net>
In-Reply-To
<cover-0.5-00000000000-20210701T104855Z-avarab@gmail.com>
On Thu, Jul 01, 2021 at 12:51:24PM +0200, Ævar Arnfjörð Bjarmason wrote:
> This series implements a suggestion by Jeff King to use an idiom for
> *_init() functions that avoids duplicating what we've declared in the
> corresponding *_INIT macros. See
> https://lore.kernel.org/git/YNytp0JAIaQih0Y4@coredump.intra.peff.net/

These all look pretty good to me. My comments are minor enough that I'll include them here rather than individual replies:

> Ævar Arnfjörð Bjarmason (5):
>   *.h: move some *_INIT to designated initializers

I agree with Martin's suggestion to prefer the designated initializer for STRING_LIST_INIT_NODUP. The consistency makes it easier to read.

>   *.c *_init(): define in terms of corresponding *_INIT macro
Yep, nice.
>   dir.[ch]: replace dir_init() with DIR_INIT

I like this. Since there is a dir_clear(), I guess somebody could argue that lacking an init function makes things less consistent/balanced. But if we don't need it, I'm happy to drop it.

>   string-list.[ch]: add a string_list_init_{nodup,dup}()

I like this. I agree the current "0/1" in the callers is kind of inscrutable. It does make things harder if we wanted to add more options, but that is already true due to the macro initializers.

>   string-list.h users: change to use *_{nodup,dup}()

Nice. IMHO you should drop the convenience wrapper here. Leaving it means we'll have to circle back later and fix up topics in flight (and it's not atomic; when we finally drop it, there may be more topics in flight then!).

If it were somehow complicated to convert callers, that might be more justified. But doing a quick conversion (which is easily detected by the compiler) in the merge commit seems like less work than having to revisit the topic later.

-Peff
Previous: Ævar Arnfjörð Bjarmason
Message 10 of 10 in “*.[ch]: don't duplicate *_init() and *_INIT logic”
  1. 0/5 *.[ch]: don't duplicate *_init() and *_INIT logicÆvar Arnfjörð Bjarmason, Jul 1, 2021
  2. 3/5 dir.[ch]: replace dir_init() with DIR_INITÆvar Arnfjörð Bjarmason, Jul 1, 2021
  3. 2/5 *.c *_init(): define in terms of corresponding *_INIT macroÆvar Arnfjörð Bjarmason, Jul 1, 2021
  4. 1/5 *.h: move some *_INIT to designated initializersÆvar Arnfjörð Bjarmason, Jul 1, 2021
  5. Martin ÅgrenJul 1, 2021
  6. Junio C HamanoJul 1, 2021
  7. Ævar Arnfjörð BjarmasonJul 1, 2021
  8. 5/5 string-list.h users: change to use *_{nodup,dup}()Ævar Arnfjörð Bjarmason, Jul 1, 2021
  9. 4/5 string-list.[ch]: add a string_list_init_{nodup,dup}()Ævar Arnfjörð Bjarmason, Jul 1, 2021
  10. Jeff KingJul 1, 2021

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.