From: Neil Brown Date: Mon, 22 Aug 2011 08:08:08 +0000 (+1000) Subject: Avoid use of undefined variable in bestmatch. X-Git-Tag: v0.9~67 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=56dc260317d4f9d7231149341a17896f23b7086d;p=wiggle.git Avoid use of undefined variable in bestmatch. When v->val is <= 0, v->k doesn't mean anything and isn't needed, so avoid using it. This helps make valgrind happy. Signed-off-by: NeilBrown --- diff --git a/bestmatch.c b/bestmatch.c index 89e8c2d..4750425 100644 --- a/bestmatch.c +++ b/bestmatch.c @@ -59,7 +59,7 @@ struct v { int x,y; /* location of start of match */ int val; /* value of match from x,y to here */ - int k; /* diagonal of last match */ + int k; /* diagonal of last match - if val > 0 */ int inmatch; /* 1 if last point was a match */ int c; /* chunk number */ }; @@ -112,7 +112,7 @@ static inline void update_value(struct v *v, int dir, int k, int x) v->val += 2+v->inmatch; v->inmatch = 1; v->k = k; - } else { + } else if (v->val > 0) { v->inmatch = 0; if (dir * (v->k - k) > 0) { /* other half of replacement */ @@ -121,6 +121,7 @@ static inline void update_value(struct v *v, int dir, int k, int x) } } } + static inline int best_val(struct v *v, int max) { if (v->val <= 0)