]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 't/clang'
authorAndre Noll <maan@systemlinux.org>
Wed, 11 Jul 2012 23:53:14 +0000 (01:53 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 11 Jul 2012 23:57:17 +0000 (01:57 +0200)
869f0e aft.c: Silence scan-build warning.
4cdf53 mood: Improve readability of get_item_score().
ec5040 mood: Add score value only for admissible files.
76d527 client: Remove pointless assignment.
466c9b gcrypt: Remove pointless assignment.
98c13e gcrypt: Remove dead stores.
d458c2 mp3dec: Remove dead store.

Cooking for quite some time - no problems.

NEWS
aft.c
client.c
gcrypt.c
mood.c
mp3dec_filter.c

diff --git a/NEWS b/NEWS
index d38b977c60dcb73cc32370177dddd20b50c9cd6e..9a84c332001ddc5d0cdf4fbf769550b4c9387790 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@
        - The alsa writer now limits the prebuffer time to 500ms.
        - Documentation improvements.
        - Overhaul of the command_util.sh script.
+       - Fixes for some minor problems found by the clang analyzer.
 
 ------------------------------------------
 0.4.10 (2012-03-30) "heterogeneous vacuum"
diff --git a/aft.c b/aft.c
index 2732790938442822e983205a164cc5f09185a049..f01f1868e60b1592c9bde8f0d371234edd60d23a 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -1277,8 +1277,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;
index c194e1929b9dfa2cb7704ca1f6b78dd704eb3815..f0f3b2617be6f3554250cedfafbbcc92c38f54b7 100644 (file)
--- a/client.c
+++ b/client.c
@@ -307,7 +307,7 @@ static void setatt_completer(struct i9e_completion_info *ci,
                free(orig);
        }
        sl[2 * num_atts] = NULL;
-       ret = i9e_extract_completions(ci->word, sl, &cr->matches);
+       i9e_extract_completions(ci->word, sl, &cr->matches);
 out:
        free(buf);
        free_argv(sl);
index 926eb15f41ae479b167a0b9a694b972c6f88fcfd..aaf97d424b4e5725c025288d4dd5cc341da9a6a2 100644 (file)
--- a/gcrypt.c
+++ b/gcrypt.c
@@ -499,7 +499,6 @@ static int get_private_key(const char *key_file, struct asymmetric_key **result)
        ret = read_bignum(cp, end, &u, NULL);
        if (ret < 0)
                goto release_q;
-       cp += ret;
        /*
         * OpenSSL uses slightly different parameters than gcrypt. To use these
         * parameters we need to swap the values of p and q and recompute u.
@@ -574,7 +573,6 @@ static int get_asn_public_key(const char *key_file, struct asymmetric_key **resu
        ret = read_bignum(cp, end, &e, NULL);
        if (ret < 0)
                goto release_n;
-       cp += ret;
 
        gret = gcry_sexp_build(&sexp, &erroff, RSA_PUBKEY_SEXP, n, e);
        if (gret) {
@@ -697,7 +695,6 @@ int get_asymmetric_key(const char *key_file, int private,
        key->num_bytes = ret;
        key->sexp = sexp;
        *result = key;
-       ret = key->num_bytes;
 unmap:
        ret2 = para_munmap(map, map_size);
        if (ret >= 0 && ret2 < 0)
diff --git a/mood.c b/mood.c
index bafe710c09372a7e8a1f82168324d9a64a0e633e..e905f92cc64b4e99d55691d3d9e5805e3f3985d1 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -108,12 +108,16 @@ __a_const static uint64_t int_sqrt(uint64_t x)
        return res;
 }
 
-/* returns 1 if row matches score item, 0 if not. */
-static int get_item_score(struct mood_item *item, const struct afs_info *afsi,
+/*
+ * Returns true if row matches, false if it does not match. In any case score
+ * and score_arg_sum are set/increased accordingly.
+ */
+static bool get_item_score(struct mood_item *item, const struct afs_info *afsi,
                const struct afh_info *afhi, const char *path, long *score,
                long *score_arg_sum)
 {
-       int ret, match = 1;
+       int ret;
+       bool match = true;
 
        *score_arg_sum += item->random_score? 100 : PARA_ABS(item->score_arg);
        ret = 100;
@@ -121,7 +125,7 @@ static int get_item_score(struct mood_item *item, const struct afs_info *afsi,
                ret = item->method->score_function(path, afsi, afhi,
                        item->parser_data);
                if ((ret < 0 && !item->logical_not) || (ret >= 0 && item->logical_not))
-                       match = 0; /* no match */
+                       match = false;
        }
        if (item->random_score)
                *score = PARA_ABS(ret) * para_random(100);
@@ -135,7 +139,8 @@ static int compute_mood_score(const struct osl_row *aft_row, struct mood *m,
                long *result)
 {
        struct mood_item *item;
-       int ret, match = 0;
+       int ret;
+       bool match;
        long score_arg_sum = 0, score = 0, item_score;
        struct afs_info afsi;
        struct afh_info afhi;
@@ -154,27 +159,29 @@ static int compute_mood_score(const struct osl_row *aft_row, struct mood *m,
                return ret;
        /* reject audio file if it matches any entry in the deny list */
        list_for_each_entry(item, &m->deny_list, mood_item_node) {
-               ret = get_item_score(item, &afsi, &afhi, path, &item_score,
+               match = get_item_score(item, &afsi, &afhi, path, &item_score,
                        &score_arg_sum);
-               if (ret > 0) /* not admissible */
+               if (match) /* not admissible */
                        return 0;
                score += item_score;
        }
+       match = false;
        list_for_each_entry(item, &m->accept_list, mood_item_node) {
                ret = get_item_score(item, &afsi, &afhi, path, &item_score,
                        &score_arg_sum);
                if (ret == 0)
                        continue;
-               match = 1;
+               match = true;
                score += item_score;
        }
        /* reject if there is no matching entry in the accept list */
        if (!match && !list_empty(&m->accept_list))
                return 0;
        list_for_each_entry(item, &m->score_list, mood_item_node) {
-               ret = get_item_score(item, &afsi, &afhi, path, &item_score,
+               match = get_item_score(item, &afsi, &afhi, path, &item_score,
                        &score_arg_sum);
-               score += item_score;
+               if (match)
+                       score += item_score;
        }
        if (score_arg_sum)
                score /= score_arg_sum;
index 4bdbc6fd5dc84b6fd73e7678dd04affba1eb6c4b..6955a7423650f3b929b807b6184221d5b5773717 100644 (file)
@@ -130,7 +130,7 @@ decode:
                ret = handle_decode_error(pmd);
                if (ret < 0)
                        goto err;
-               ret = mad_stream_sync(&pmd->stream);
+               mad_stream_sync(&pmd->stream);
                if (pmd->stream.error == MAD_ERROR_BUFLEN) {
                        ret = -E_MP3DEC_EOF;
                        if (len == iqs && btr_no_parent(btrn))