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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]