{"thread":{"id":"48087","subject":"PATCH 1/2] -Wuninitialized: remove some 'init-self' workarounds","startedAt":"2018-03-19T17:54:47Z","lastAt":"2018-03-20T17:00:01Z","messageCount":3,"participants":["Ramsay Jones","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"342218","messageId":"946e0ff9-307c-6886-6ade-7bd37cc9f97f@ramsayjones.plus.com","threadId":"48087","inReplyTo":null,"subject":"PATCH 1/2] -Wuninitialized: remove some 'init-self' workarounds","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2018-03-19T17:54:35Z","receivedAt":"2018-03-19T17:54:47Z","isPatch":false,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nThe 'self-initialised' variables construct (ie <type> var = var;) has\nbeen used to silence gcc '-W[maybe-]uninitialized' warnings. This has,\nunfortunately, caused MSVC to issue 'uninitialized variable' warnings.\nAlso, using clang static analysis causes complaints about an 'Assigned\nvalue is garbage or undefined'.\n\nThere are six such constructs in the current codebase. Only one of the\nsix causes gcc to issue a '-Wmaybe-uninitialized' warning (which will\nbe addressed elsewhere). The remaining five 'init-self' gcc workarounds\nare noted below, along with the commit which introduced them:\n\n  1. builtin/rev-list.c: 'reaches' and 'all', see commit 457f08a030\n     (\"git-rev-list: add --bisect-vars option.\", 2007-03-21).\n\n  2. merge-recursive.c:2064 'mrtree', see commit f120ae2a8e (\"merge-\n     recursive.c: mrtree in merge() is not used before set\", 2007-10-29).\n\n  3. fast-import.c:3023 'oe', see commit 85c62395b1 (\"fast-import: let\n     importers retrieve blobs\", 2010-11-28).\n\n  4. fast-import.c:3006 'oe', see commit 28c7b1f7b7 (\"fast-import: add a\n     get-mark command\", 2015-07-01).\n\nRemove the 'self-initialised' variable constructs noted above.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n builtin/rev-list.c | 2 +-\n fast-import.c      | 4 ++--\n merge-recursive.c  | 2 +-\n 3 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex d5345b6a2..fbfc62de4 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -479,7 +479,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \t\tmark_edges_uninteresting(&revs, show_edge);\n \n \tif (bisect_list) {\n-\t\tint reaches = reaches, all = all;\n+\t\tint reaches, all;\n \n \t\tfind_bisection(&revs.commits, &reaches, &all, bisect_find_all);\n \ndiff --git a/fast-import.c b/fast-import.c\nindex b70ac025e..1f01a2205 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -3003,7 +3003,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)\n \n static void parse_get_mark(const char *p)\n {\n-\tstruct object_entry *oe = oe;\n+\tstruct object_entry *oe;\n \tchar output[GIT_MAX_HEXSZ + 2];\n \n \t/* get-mark SP <object> LF */\n@@ -3020,7 +3020,7 @@ static void parse_get_mark(const char *p)\n \n static void parse_cat_blob(const char *p)\n {\n-\tstruct object_entry *oe = oe;\n+\tstruct object_entry *oe;\n \tstruct object_id oid;\n \n \t/* cat-blob SP <object> LF */\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 0fc580d8c..fa9067eec 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -2061,7 +2061,7 @@ int merge_recursive(struct merge_options *o,\n {\n \tstruct commit_list *iter;\n \tstruct commit *merged_common_ancestors;\n-\tstruct tree *mrtree = mrtree;\n+\tstruct tree *mrtree;\n \tint clean;\n \n \tif (show(o, 4)) {\n-- \n2.16.0\n"},{"id":"342271","messageId":"c9748dfd-4293-140f-e753-8736bc196ab0@ramsayjones.plus.com","threadId":"48087","inReplyTo":"946e0ff9-307c-6886-6ade-7bd37cc9f97f@ramsayjones.plus.com","subject":"Re: PATCH 1/2] -Wuninitialized: remove some 'init-self' workarounds","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2018-03-20T01:33:54Z","receivedAt":"2018-03-20T01:34:04Z","isPatch":false,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 19/03/18 17:54, Ramsay Jones wrote:\n> \n> The 'self-initialised' variables construct (ie <type> var = var;) has\n> been used to silence gcc '-W[maybe-]uninitialized' warnings. This has,\n> unfortunately, caused MSVC to issue 'uninitialized variable' warnings.\n> Also, using clang static analysis causes complaints about an 'Assigned\n> value is garbage or undefined'.\n> \n[snip]\n\nHi Junio,\n\nYou may not have noticed that I messed up the Subject line of\nthis patch - I managed to drop the '[' character in the patch\nprefix string. :(\n\nSo, the commit 7bc195d877 on the 'pu' branch is titled:\n\n  \"PATCH 1/2] -Wininitialized: remove some 'init-self' workarounds\"\n\nAhem! Sorry about that.\n\nATB,\nRamsay Jones\n\n\n"},{"id":"342342","messageId":"xmqqvadqsmwm.fsf@gitster-ct.c.googlers.com","threadId":"48087","inReplyTo":"c9748dfd-4293-140f-e753-8736bc196ab0@ramsayjones.plus.com","subject":"Re: PATCH 1/2] -Wuninitialized: remove some 'init-self' workarounds","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-03-20T16:59:53Z","receivedAt":"2018-03-20T17:00:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n\n> You may not have noticed that I messed up the Subject line of\n> this patch - I managed to drop the '[' character in the patch\n> prefix string. :(\n\nI did notice the lack of '[' while reading, and then totally forgot\nby the time I started queuing various topics.\n\nThanks for reminding.\n\n> So, the commit 7bc195d877 on the 'pu' branch is titled:\n>\n>   \"PATCH 1/2] -Wininitialized: remove some 'init-self' workarounds\"\n>\n> Ahem! Sorry about that.\n>\n> ATB,\n> Ramsay Jones\n"}]}