Skip to content

Commit 31e703c

Browse files
pks-tgitster
authored andcommitted
reftable/stack: fix compiler warning due to missing braces
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/[email protected]/T/ Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0f0f0ed commit 31e703c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

reftable/stack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ struct reftable_addition {
704704
uint64_t next_update_index;
705705
};
706706

707-
#define REFTABLE_ADDITION_INIT {0}
707+
#define REFTABLE_ADDITION_INIT {{0}}
708708

709709
static int reftable_stack_init_addition(struct reftable_addition *add,
710710
struct reftable_stack *st,

0 commit comments

Comments
 (0)