Skip to contentSkip to conversation

jt/fetch-cdn-offload: fix build with clang

PATCH In review Johannes Schindelin via GitGitGadget 3 participants 5 messages Feb 24, 2019 – Mar 11, 2019

lore
Share & tools
lore
#0 lore raw

cover jt/fetch-cdn-offload: fix build with clang

I think this is actually legitimate a build error (see e.g.
https://dev.azure.com/gitgitgadget/git/_build/results?buildId=2394), and I am quite surprised that GCC accepts this.

Note: after thinking about this for a while, I guess an empty string would work, too (i.e. "" instead of " 0"), but I already waited for the macOS build to finish at https://github.com/gitgitgadget/git/pull/139, and it's a fixup! for Jonathan to pick up, anyway...

Junio, could I ask you to apply this on top of your SQUASH??? to fix the build?

Johannes Schindelin (1):
fixup! upload-pack: refactor reading of pack-objects out

 upload-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

base-commit: 2c31d711669adc7a7bfad06df37b976af99dfaa6
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-139%2Fdscho%2Fjt%2Ffetch-cdn-offload-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-139/dscho/jt/fetch-cdn-offload-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/139

Signature · 1 line
gitgitgadget
#1 lore raw

PATCH 1/1 fixup! upload-pack: refactor reading of pack-objects out

From: Johannes Schindelin <[email protected]>

This fixes an issue pointed out by clang.

---
 upload-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
upload-pack.c +1 -1
index 2365b707bc..534e8951a2 100644
@@ -179,7 +179,7 @@ static void create_pack_file(const struct object_array *have_obj,
 			     const struct string_list *uri_protocols)
 {
 	struct child_process pack_objects = CHILD_PROCESS_INIT;
-	struct output_state output_state = {0};
+	struct output_state output_state = {"\0"};
 	char progress[128];
 	char abort_msg[] = "aborting due to possible repository "
 		"corruption on the remote side.";
Signature · 1 line
gitgitgadget
#2 lore raw

Re: [PATCH 1/1] fixup! upload-pack: refactor reading of pack-objects out

"Johannes Schindelin via GitGitGadget" <[email protected]>

Quoted 14 lines · writes:

From: Johannes Schindelin <[email protected]>

This fixes an issue pointed out by clang.

---
 upload-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
upload-pack.c +0 -0
index 2365b707bc..534e8951a2 100644

upload-pack.c static void create_pack_file(const struct object_array *have_obj, · line 182

Quoted 5 lines
upload-pack.c +1 -1
@@ -179,7 +179,7 @@ static void create_pack_file(const struct object_array *have_obj,
 			     const struct string_list *uri_protocols)
 {
 	struct child_process pack_objects = CHILD_PROCESS_INIT;
-	struct output_state output_state = {0};
+	struct output_state output_state = {"\0"};

OK, as the structure looks like

	struct output_state {
		char buffer[8193];
		int used;
		...

we obviously cannot initialize buffer[] with a single integer 0 ;-) Between "" and "\0" you wondered elsewhere, I have no strong preference, but if I were fixing it, I would probably write it as

	struct output_state output_state = { { 0 } };

so that readers do not even have to waste time to wonder between the two.

Thanks.

#3 lore raw

Re: [PATCH 1/1] fixup! upload-pack: refactor reading of pack-objects out

Hi,

Quoted 30 lines · Junio C Hamano

"Johannes Schindelin via GitGitGadget" <[email protected]>

Quoted 14 lines · writes:

From: Johannes Schindelin <[email protected]>

This fixes an issue pointed out by clang.

---
 upload-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
upload-pack.c +0 -0
index 2365b707bc..534e8951a2 100644

upload-pack.c static void create_pack_file(const struct object_array *have_obj, · line 182

Quoted 5 lines
upload-pack.c +1 -1
@@ -179,7 +179,7 @@ static void create_pack_file(const struct object_array *have_obj,
 			     const struct string_list *uri_protocols)
 {
 	struct child_process pack_objects = CHILD_PROCESS_INIT;
-	struct output_state output_state = {0};
+	struct output_state output_state = {"\0"};

OK, as the structure looks like

	struct output_state {
		char buffer[8193];
		int used;
		...
Quoted 8 lines

we obviously cannot initialize buffer[] with a single integer 0 ;-) Between "" and "\0" you wondered elsewhere, I have no strong preference, but if I were fixing it, I would probably write it as

	struct output_state output_state = { { 0 } };

so that readers do not even have to waste time to wonder between the two.

Right. I don't care, as long as Jonathan addresses the compile error on clang.

Ciao,
Dscho

#4 lore raw

Re: [PATCH 1/1] fixup! upload-pack: refactor reading of pack-objects out

Hi Jonathan,

Quoted 36 lines · Johannes Schindelin
Quoted 34 lines · Junio C Hamano

"Johannes Schindelin via GitGitGadget" <[email protected]>

Quoted 14 lines · writes:

From: Johannes Schindelin <[email protected]>

This fixes an issue pointed out by clang.

---
 upload-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
upload-pack.c +0 -0
index 2365b707bc..534e8951a2 100644

upload-pack.c static void create_pack_file(const struct object_array *have_obj, · line 182

Quoted 5 lines
upload-pack.c +1 -1
@@ -179,7 +179,7 @@ static void create_pack_file(const struct object_array *have_obj,
 			     const struct string_list *uri_protocols)
 {
 	struct child_process pack_objects = CHILD_PROCESS_INIT;
-	struct output_state output_state = {0};
+	struct output_state output_state = {"\0"};

OK, as the structure looks like

	struct output_state {
		char buffer[8193];
		int used;
		...

we obviously cannot initialize buffer[] with a single integer 0 ;-) Between "" and "\0" you wondered elsewhere, I have no strong preference, but if I were fixing it, I would probably write it as

Quoted 7 lines
Quoted 4 lines
	struct output_state output_state = { { 0 } };

so that readers do not even have to waste time to wonder between the two.

Right. I don't care, as long as Jonathan addresses the compile error on clang.

This is *still* broken:
https://dev.azure.com/gitgitgadget/git/_build/results?buildId=4337

Junio, can you please in the least add my fixup! on top of jt/fetch-cdn-offload?

Thanks,
Dscho