Am 28.09.21 um 01:54 schrieb Jeff King: > On Mon, Sep 27, 2021 at 01:02:35PM +0200, Ævar Arnfjörð Bjarmason wrote: > >>>> static inline void cb_init(struct cb_tree *t) >>>> { >>>> - t->root = NULL; >>>> + struct cb_tree blank = CBTREE_INIT; >>> >>> This could be >>> >>> static const struct cb_tree blank = CBTREE_INIT; >> >> *nod*... >> [...] >> ...but to both this & the above my reply in the side-thread at >> https://lore.kernel.org/git/87h7e61duk.fsf@xxxxxxxxxxxxxxxxxxx/ >> applies. I.e. this is just following a pattern I got from Jeff King & >> used in bd4232fac33 (Merge branch 'ab/struct-init', 2021-07-16). > > I'm not sure how a compiler would react to the "static const" thing. I > tested the compiler output for the "auto" struct case you've written > here, and at least gcc and clang are smart enough to just initialize the > pointed-to struct directly, with no extra copy. Good! Then a deviation from established patterns is not warranted. -- Hannes