Subject: [PATCH 1/6] match-trees: kill off remaining -Wuninitialized warning

From: Jonathan Nieder <[email-masked]>
Date: Wed, 16 Mar 2011 06:36:29 -0500

Initialize to an invalid value (0, in this case) so we can still
catch bugs as the code evolves.

Signed-off-by: Jonathan Nieder <[email-masked]>
---
 match-trees.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/match-trees.c b/match-trees.c
index 9cfcc8b..f325ff5 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -6,6 +6,7 @@ static int score_missing(unsigned mode, const char *path)
 {
 	int score;
 
+	assert(mode);
 	if (S_ISDIR(mode))
 		score = -1000;
 	else if (S_ISLNK(mode))
@@ -19,6 +20,7 @@ static int score_differs(unsigned mode1, unsigned mode2, const char *path)
 {
 	int score;
 
+	assert(mode1 && mode2);
 	if (S_ISDIR(mode1) != S_ISDIR(mode2))
 		score = -100;
 	else if (S_ISLNK(mode1) != S_ISLNK(mode2))
@@ -32,6 +34,8 @@ static int score_matches(unsigned mode1, unsigned mode2, const char *path)
 {
 	int score;
 
+	assert(mode1 && mode2);
+
 	/* Heh, we found SHA-1 collisions between different kind of objects */
 	if (S_ISDIR(mode1) != S_ISDIR(mode2))
 		score = -100;
@@ -76,8 +80,7 @@ static int score_trees(const unsigned char *hash1, const unsigned char *hash2)
 		const unsigned char *elem2;
 		const char *path1;
 		const char *path2;
-		unsigned mode1;
-		unsigned mode2;
+		unsigned mode1 = 0, mode2 = 0;
 		int cmp;
 
 		if (one.size)
-- 
1.7.4.1