From: Andre Noll <maan@systemlinux.org>
Date: Fri, 1 Jun 2012 08:24:58 +0000 (+0200)
Subject: aft.c: Silence scan-build warning.
X-Git-Tag: v0.4.11~7^2
X-Git-Url: https://git.tuebingen.mpg.de/?a=commitdiff_plain;h=869f0e06ec4e15abc9230c1b2d7615da5250802e;p=paraslash.git

aft.c: Silence scan-build warning.

scan-build issues the following warning in prepare_ls_row():

	aft.c:1338:3: warning: Assigned value is garbage or undefined
			GET_NUM_DIGITS(score, &num_digits);
			^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	aft.c:719:21: note: expanded from:
		typeof((x)) _tmp = PARA_ABS(x); \
				   ^
	./para.h:50:2: note: expanded from:
		typeof(x) _x = (x); \
		^              ~~~

This is because clang can not prove that the "score" variable is
always initialized at this point. However, I can: The problematic
GET_NUM_DIGITS() statement is only executed if LS_FLAG_ADMISSIBLE_ONLY
is set in options->flags, but in this case "score" will be set by
get_score_and_aft_row() because this function only fails to do so if it
returns negative. In this case we return early from prepare_ls_row().

Let's make it easier for clang and initialize it anyway.
---

diff --git a/aft.c b/aft.c
index 7516e328..9e991da6 100644
--- a/aft.c
+++ b/aft.c
@@ -1276,8 +1276,10 @@ static int prepare_ls_row(struct osl_row *row, void *ls_opts)
 		ret = get_score_and_aft_row(row, &score, &aft_row);
 		if (ret < 0)
 			return ret;
-	} else
+	} else {
 		aft_row = row;
+		score = 0;
+	}
 	ret = get_audio_file_path_of_row(aft_row, &path);
 	if (ret < 0)
 		return ret;