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

[PATCH] unpack-objects: fix compilation warning/error due to missing braces

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 10, 2022, 08:11 UTC
Message-ID
<20220710081135.74964-1-sunshine@sunshineco.com>

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
Next: Han Xin
Message 1 of 13 in “unpack-objects: fix compilation warning/error due to missing braces”
  1. unpack-objects: fix compilation warning/error due to missing bracesEric Sunshine, Jul 10, 2022
  2. Han XinJul 11, 2022
  3. Eric SunshineJul 11, 2022
  4. Junio C HamanoJul 11, 2022
  5. Eric SunshineJul 12, 2022
  6. Ævar Arnfjörð BjarmasonJul 12, 2022
  7. Eric SunshineJul 12, 2022
  8. Jeff KingJul 12, 2022
  9. Eric SunshineJul 12, 2022
  10. Ævar Arnfjörð BjarmasonJul 12, 2022
  11. Jeff KingJul 14, 2022
  12. Ævar Arnfjörð BjarmasonJul 15, 2022
  13. Junio C HamanoJul 12, 2022

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.