threads / patch / 49609

patchmulti-pack-index: avoid dead store for struct progress

Subject: [PATCH] multi-pack-index: avoid dead store for struct progress

## tl;dr

4 messages between Oct 18, 2018 and Oct 19, 2018. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Carlo Marcelo Arenas Belón· Oct 18, 2018, 18:59 UTC · lore

it is initialized unconditionally by a call to start_progress below.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 midx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to midx.c +1 −1
diff --git a/midx.c b/midx.c
index ea2f3ffe2e..4fac0cd08a 100644
--- a/midx.c
+++ b/midx.c
@@ -941,7 +941,7 @@ static void midx_report(const char *fmt, ...)
 int verify_midx_file(const char *object_dir)
 {
 	uint32_t i;
-	struct progress *progress = NULL;
+	struct progress *progress;
 	struct multi_pack_index *m = load_multi_pack_index(object_dir, 1);
 	verify_midx_error = 0;
 
-- 
2.19.1
Derrick Stolee· Oct 18, 2018, 19:36 UTC · re: Carlo Marcelo Arenas Belón · lore

Re: [PATCH] multi-pack-index: avoid dead store for struct progress

On 10/18/2018 2:59 PM, Carlo Marcelo Arenas Belón wrote:
Show 21 quoted lines
> it is initialized unconditionally by a call to start_progress
> below.
>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
>   midx.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/midx.c b/midx.c
> index ea2f3ffe2e..4fac0cd08a 100644
> --- a/midx.c
> +++ b/midx.c
> @@ -941,7 +941,7 @@ static void midx_report(const char *fmt, ...)
>   int verify_midx_file(const char *object_dir)
>   {
>   	uint32_t i;
> -	struct progress *progress = NULL;
> +	struct progress *progress;
>   	struct multi_pack_index *m = load_multi_pack_index(object_dir, 1);
>   	verify_midx_error = 0;
>   

This makes sense as a cleanup. Is there a tool that reports a wasted initialization that you used to find this?

-Stolee
Carlo Arenas· Oct 18, 2018, 19:56 UTC · re: Derrick Stolee · lore

Re: [PATCH] multi-pack-index: avoid dead store for struct progress

On Thu, Oct 18, 2018 at 12:36 PM Derrick Stolee <stolee@gmail.com> wrote:
>
> Is there a tool that reports a wasted
> initialization that you used to find this?

I'd used clang's analyzer recently to track a similar issue before in a different codebase, but not for this specific case.

Carlo
Junio C Hamano· Oct 19, 2018, 02:26 UTC · re: Carlo Marcelo Arenas Belón · lore

Re: [PATCH] multi-pack-index: avoid dead store for struct progress

Carlo Marcelo Arenas Belón  <carenas@gmail.com> writes:
Show 20 quoted lines
> it is initialized unconditionally by a call to start_progress
> below.
>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
>  midx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/midx.c b/midx.c
> index ea2f3ffe2e..4fac0cd08a 100644
> --- a/midx.c
> +++ b/midx.c
> @@ -941,7 +941,7 @@ static void midx_report(const char *fmt, ...)
>  int verify_midx_file(const char *object_dir)
>  {
>  	uint32_t i;
> -	struct progress *progress = NULL;
> +	struct progress *progress;
>  	struct multi_pack_index *m = load_multi_pack_index(object_dir, 1);
>  	verify_midx_error = 0;

Both changes make sense. It's kind of surprising that this still matters, though; I would have expected a compiler would notice.

← back to recent threads