{"thread":{"id":"25967","subject":"[PATCH 06/14] match-trees.c: Initialise variables to suppress msvc warnings","startedAt":"2010-12-04T19:05:47Z","lastAt":"2010-12-04T19:05:47Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":1,"patchTotal":14},"messages":[{"id":"157330","messageId":"4CFA910B.6040708@ramsay1.demon.co.uk","threadId":"25967","inReplyTo":null,"subject":"[PATCH 06/14] match-trees.c: Initialise variables to suppress msvc warnings","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2010-12-04T19:05:47Z","receivedAt":"2010-12-04T19:05:47Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nThe msvc compiler thinks that several variables could be used\nwhile uninitialised and issues 12 warnings like:\n\n    ...\\git\\match-trees.c(75) : warning C4700: uninitialized local \\\n        variable 'elem1' used\n    ...\\git\\match-trees.c(76) : warning C4700: uninitialized local \\\n        variable 'elem2' used\n    ...\\git\\match-trees.c(77) : warning C4700: uninitialized local \\\n        variable 'path1' used\n    ...\\git\\match-trees.c(78) : warning C4700: uninitialized local \\\n        variable 'path2' used\n    ...\\git\\match-trees.c(79) : warning C4700: uninitialized local \\\n        variable 'mode1' used\n    ...\\git\\match-trees.c(80) : warning C4700: uninitialized local \\\n        variable 'mode2' used\n\nIn order to suppress the warnings, we simply initialise the char\npointer variables to NULL and the int variables to zero.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n match-trees.c |   12 ++++++------\n 1 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/match-trees.c b/match-trees.c\nindex 26f7ed1..de050d0 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -72,12 +72,12 @@ static int score_trees(const unsigned char *hash1, const unsigned char *hash2)\n \t\tdie(\"%s is not a tree\", sha1_to_hex(hash2));\n \tinit_tree_desc(&two, two_buf, size);\n \twhile (one.size | two.size) {\n-\t\tconst unsigned char *elem1 = elem1;\n-\t\tconst unsigned char *elem2 = elem2;\n-\t\tconst char *path1 = path1;\n-\t\tconst char *path2 = path2;\n-\t\tunsigned mode1 = mode1;\n-\t\tunsigned mode2 = mode2;\n+\t\tconst unsigned char *elem1 = NULL;\n+\t\tconst unsigned char *elem2 = NULL;\n+\t\tconst char *path1 = NULL;\n+\t\tconst char *path2 = NULL;\n+\t\tunsigned mode1 = 0;\n+\t\tunsigned mode2 = 0;\n \t\tint cmp;\n \n \t\tif (one.size)\n-- \n1.7.3\n"}]}