threads / patch / 50580

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

Subject: [PATCH 0/1] jt/fetch-cdn-offload: fix build with clang

## tl;dr

5 messages between Feb 24, 2019 and Mar 11, 2019. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

Johannes Schindelin via GitGitGadget· Feb 24, 2019, 22:12 UTC · lore

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
-- 
gitgitgadget
Johannes Schindelin via GitGitGadget· Feb 24, 2019, 22:12 UTC · re: Johannes Schindelin via GitGitGadget · lore

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

From: Johannes Schindelin <johannes.schindelin@gmx.de>
This fixes an issue pointed out by clang.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 upload-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to upload-pack.c +1 −1
diff --git a/upload-pack.c b/upload-pack.c
index 2365b707bc..534e8951a2 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -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.";
-- 
gitgitgadget
Junio C Hamano· Mar 3, 2019, 01:21 UTC · re: Johannes Schindelin via GitGitGadget · lore

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

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:

Show 19 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> This fixes an issue pointed out by clang.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  upload-pack.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/upload-pack.c b/upload-pack.c
> index 2365b707bc..534e8951a2 100644
> --- a/upload-pack.c
> +++ b/upload-pack.c
> @@ -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.
Johannes Schindelin· Mar 3, 2019, 15:01 UTC · re: Junio C Hamano · lore

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

Hi,
On Sun, 3 Mar 2019, Junio C Hamano wrote:
Show 38 quoted lines
> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
> 
> > From: Johannes Schindelin <johannes.schindelin@gmx.de>
> >
> > This fixes an issue pointed out by clang.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> >  upload-pack.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/upload-pack.c b/upload-pack.c
> > index 2365b707bc..534e8951a2 100644
> > --- a/upload-pack.c
> > +++ b/upload-pack.c
> > @@ -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.

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

Ciao, Dscho

Johannes Schindelin· Mar 11, 2019, 12:54 UTC · re: Johannes Schindelin · lore

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

Hi Jonathan,
On Sun, 3 Mar 2019, Johannes Schindelin wrote:
Show 43 quoted lines
> On Sun, 3 Mar 2019, Junio C Hamano wrote:
> 
> > "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> > writes:
> > 
> > > From: Johannes Schindelin <johannes.schindelin@gmx.de>
> > >
> > > This fixes an issue pointed out by clang.
> > >
> > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > > ---
> > >  upload-pack.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/upload-pack.c b/upload-pack.c
> > > index 2365b707bc..534e8951a2 100644
> > > --- a/upload-pack.c
> > > +++ b/upload-pack.c
> > > @@ -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.
> 
> 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

← back to recent threads