From: Patrick Steinhardt Date: Mon, 04 Aug 2025 09:40:24 GMT Subject: [PATCH v2 3/6] reftable/stack: fix compiler warning due to missing braces Message-ID: <20250804-pks-reftable-fixes-for-libgit2-v2-3-fef06209a984@pks.im> In-Reply-To: <20250804-pks-reftable-fixes-for-libgit2-v2-0-fef06209a984@pks.im> While perfectly legal, older compiler toolchains complain when zero-initializing structs that contain nested structs with `{0}`: /home/libgit2/source/deps/reftable/stack.c:862:35: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] struct reftable_addition empty = REFTABLE_ADDITION_INIT; ^~~~~~~~~~~~~~~~~~~~~~ /home/libgit2/source/deps/reftable/stack.c:707:33: note: expanded from macro 'REFTABLE_ADDITION_INIT' #define REFTABLE_ADDITION_INIT {0} ^ Silence this warning by using `{{0}}` instead. Note that we had the discussion around whether or not we want to handle such errors in the past already [1], where we basically decided that we do not care about such old-and-buggy compilers. But the reftable library is a special case because it is used by projects other than Git, and libgit2 for example hits the above issue in its pipeline. As there is only a single problematic instance of this issue we do the pragmatic thing and simply make the compiler happy. [1]: https://lore.kernel.org/git/20220710081135.74964-1-sunshine@sunshineco.com/T/ Signed-off-by: Patrick Steinhardt --- reftable/stack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reftable/stack.c b/reftable/stack.c index 4caf96aa1d..3480ad21c3 100644 --- a/reftable/stack.c +++ b/reftable/stack.c @@ -704,7 +704,7 @@ struct reftable_addition { uint64_t next_update_index; }; -#define REFTABLE_ADDITION_INIT {0} +#define REFTABLE_ADDITION_INIT {{0}} static int reftable_stack_init_addition(struct reftable_addition *add, struct reftable_stack *st, -- 2.50.1.723.g3e08bea96f.dirty