diff mbox series

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

Message ID 5fa4fcad63e18dd9d840217eb8cf3dab8f69bc1b.1551046329.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series jt/fetch-cdn-offload: fix build with clang | expand

Commit Message

John Passaro via GitGitGadget Feb. 24, 2019, 10:12 p.m. UTC
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(-)

Comments

Junio C Hamano March 3, 2019, 1:21 a.m. UTC | #1
"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.

Thanks.
Johannes Schindelin March 3, 2019, 3:01 p.m. UTC | #2
Hi,

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.

Ciao,
Dscho
Johannes Schindelin March 11, 2019, 12:54 p.m. UTC | #3
Hi Jonathan,

On Sun, 3 Mar 2019, Johannes Schindelin wrote:

> 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
diff mbox series

Patch

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.";