{"thread":{"id":"49609","subject":"[PATCH] multi-pack-index: avoid dead store for struct progress","startedAt":"2018-10-18T18:59:42Z","lastAt":"2018-10-19T02:26:29Z","messageCount":4,"participants":["Carlo Marcelo Arenas Belón","Derrick Stolee","Carlo Arenas","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"360865","messageId":"20181018185920.22975-1-carenas@gmail.com","threadId":"49609","inReplyTo":null,"subject":"[PATCH] multi-pack-index: avoid dead store for struct progress","fromName":"Carlo Marcelo Arenas Belón","fromEmail":"carenas@gmail.com","sentAt":"2018-10-18T18:59:20Z","receivedAt":"2018-10-18T18:59:42Z","isPatch":true,"sender":{"key":"carenas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/76036?v=4"},"body":"it is initialized unconditionally by a call to start_progress\nbelow.\n\nSigned-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>\n---\n midx.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/midx.c b/midx.c\nindex ea2f3ffe2e..4fac0cd08a 100644\n--- a/midx.c\n+++ b/midx.c\n@@ -941,7 +941,7 @@ static void midx_report(const char *fmt, ...)\n int verify_midx_file(const char *object_dir)\n {\n \tuint32_t i;\n-\tstruct progress *progress = NULL;\n+\tstruct progress *progress;\n \tstruct multi_pack_index *m = load_multi_pack_index(object_dir, 1);\n \tverify_midx_error = 0;\n \n-- \n2.19.1\n\n"},{"id":"360870","messageId":"16e462a7-cdd6-9d5d-d740-d5241485787b@gmail.com","threadId":"49609","inReplyTo":"20181018185920.22975-1-carenas@gmail.com","subject":"Re: [PATCH] multi-pack-index: avoid dead store for struct progress","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-10-18T19:36:03Z","receivedAt":"2018-10-18T19:36:07Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 10/18/2018 2:59 PM, Carlo Marcelo Arenas Belón wrote:\n> it is initialized unconditionally by a call to start_progress\n> below.\n>\n> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>\n> ---\n>   midx.c | 2 +-\n>   1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/midx.c b/midx.c\n> index ea2f3ffe2e..4fac0cd08a 100644\n> --- a/midx.c\n> +++ b/midx.c\n> @@ -941,7 +941,7 @@ static void midx_report(const char *fmt, ...)\n>   int verify_midx_file(const char *object_dir)\n>   {\n>   \tuint32_t i;\n> -\tstruct progress *progress = NULL;\n> +\tstruct progress *progress;\n>   \tstruct multi_pack_index *m = load_multi_pack_index(object_dir, 1);\n>   \tverify_midx_error = 0;\n>   \nThis makes sense as a cleanup. Is there a tool that reports a wasted \ninitialization that you used to find this?\n\n-Stolee\n"},{"id":"360871","messageId":"CAPUEspixnjOm7YAuCgCTfmWf28kF8jCACD=-VHNDAeL2Gu8mQQ@mail.gmail.com","threadId":"49609","inReplyTo":"16e462a7-cdd6-9d5d-d740-d5241485787b@gmail.com","subject":"Re: [PATCH] multi-pack-index: avoid dead store for struct progress","fromName":"Carlo Arenas","fromEmail":"carenas@gmail.com","sentAt":"2018-10-18T19:56:32Z","receivedAt":"2018-10-18T19:56:45Z","isPatch":true,"sender":{"key":"carenas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/76036?v=4"},"body":"On Thu, Oct 18, 2018 at 12:36 PM Derrick Stolee <stolee@gmail.com> wrote:\n>\n> Is there a tool that reports a wasted\n> initialization that you used to find this?\n\nI'd used clang's analyzer recently to track a similar issue before in a\ndifferent codebase, but not for this specific case.\n\nCarlo\n"},{"id":"360893","messageId":"xmqqr2gm3c4v.fsf@gitster-ct.c.googlers.com","threadId":"49609","inReplyTo":"20181018185920.22975-1-carenas@gmail.com","subject":"Re: [PATCH] multi-pack-index: avoid dead store for struct progress","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-10-19T02:26:24Z","receivedAt":"2018-10-19T02:26:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Carlo Marcelo Arenas Belón  <carenas@gmail.com> writes:\n\n> it is initialized unconditionally by a call to start_progress\n> below.\n>\n> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>\n> ---\n>  midx.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/midx.c b/midx.c\n> index ea2f3ffe2e..4fac0cd08a 100644\n> --- a/midx.c\n> +++ b/midx.c\n> @@ -941,7 +941,7 @@ static void midx_report(const char *fmt, ...)\n>  int verify_midx_file(const char *object_dir)\n>  {\n>  \tuint32_t i;\n> -\tstruct progress *progress = NULL;\n> +\tstruct progress *progress;\n>  \tstruct multi_pack_index *m = load_multi_pack_index(object_dir, 1);\n>  \tverify_midx_error = 0;\n\nBoth changes make sense.  It's kind of surprising that this still\nmatters, though; I would have expected a compiler would notice.\n"}]}