[PATCH 1/6] match-trees: kill off remaining -Wuninitialized warning
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Mar 16, 2011, 11:36 UTC
- Message-ID
- <20110316113629.GC15739@elie>
- In-Reply-To
- <20110316113540.GB15739@elie>
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@gmail.com> --- 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