From 869f0e06ec4e15abc9230c1b2d7615da5250802e Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 1 Jun 2012 10:24:58 +0200 Subject: [PATCH] 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. --- aft.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- 2.39.5