git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] unpack-objects: fix compilation warning/error due to missing braces
@ 2022-07-10  8:11 Eric Sunshine
  2022-07-11  2:00 ` Han Xin
  0 siblings, 1 reply; 13+ messages in thread
From: Eric Sunshine @ 2022-07-10  8:11 UTC (permalink / raw)
  To: git; +Cc: Han Xin, Ævar Arnfjörð Bjarmason, Eric Sunshine

On macOS High Sierra (10.13), Apple's `clang`[1] complains about missing
braces around initialization of a subobject, which is problematic when
building with `DEVELOPER=YesPlease` which enables `-Werror`:

    builtin/unpack-objects.c:388:26: error: suggest braces around
        initialization of subobject [-Werror,-Wmissing-braces]
            git_zstream zstream = { 0 };

[1]: `cc --version` => "Apple LLVM version 10.0.0 (clang-1000.10.44.4)"

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---

Notes:
    This is atop 'hx/unpack-streaming' which is already in 'next'.
    All the CI builds are fine with this change.

    As I understand it, this should be a safe change; the fields which
    follow `z_stream z` in `git_zstream` will be initialized to zero
    since the first field has an explicit initializer.

 builtin/unpack-objects.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 43789b8ef2..c606c92e37 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -385,7 +385,7 @@ static const void *feed_input_zstream(struct input_stream *in_stream,
 
 static void stream_blob(unsigned long size, unsigned nr)
 {
-	git_zstream zstream = { 0 };
+	git_zstream zstream = {{ 0 }};
 	struct input_zstream_data data = { 0 };
 	struct input_stream in_stream = {
 		.read = feed_input_zstream,
-- 
2.37.0.236.gcef32db0b6.dirty


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-07-15  8:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-10  8:11 [PATCH] unpack-objects: fix compilation warning/error due to missing braces Eric Sunshine
2022-07-11  2:00 ` Han Xin
2022-07-11  2:41   ` Eric Sunshine
2022-07-11  4:38     ` Junio C Hamano
2022-07-12  6:28       ` Eric Sunshine
2022-07-12  6:41         ` Ævar Arnfjörð Bjarmason
2022-07-12  7:13           ` Eric Sunshine
2022-07-12  7:23             ` Jeff King
2022-07-12  7:33               ` Eric Sunshine
2022-07-12  9:16               ` Ævar Arnfjörð Bjarmason
2022-07-14 21:54                 ` Jeff King
2022-07-15  8:20                   ` Ævar Arnfjörð Bjarmason
2022-07-12 14:46             ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).