From dbee2f63ee747b5d4247038f27566bc5aebfe3b7 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 11 Oct 2010 18:39:56 +0400 Subject: Fixes bugs found with clang-static analyser. Strictly follow c99 standart. Turn on pedantic c99 checks. --- src/classifiers/bayes.c | 1 + src/classifiers/winnow.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/classifiers') diff --git a/src/classifiers/bayes.c b/src/classifiers/bayes.c index 1ce36e0bd..7bc3fde54 100644 --- a/src/classifiers/bayes.c +++ b/src/classifiers/bayes.c @@ -282,6 +282,7 @@ bayes_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symb 1, /* error code */ "cannot find statfile for symbol: %s", symbol); + return FALSE; } if ((to_learn = statfile_pool_is_open (pool, sel_st->path)) == NULL) { if ((to_learn = statfile_pool_open (pool, sel_st->path, sel_st->size, FALSE)) == NULL) { diff --git a/src/classifiers/winnow.c b/src/classifiers/winnow.c index f1f991486..b7fe4e123 100644 --- a/src/classifiers/winnow.c +++ b/src/classifiers/winnow.c @@ -361,9 +361,9 @@ winnow_learn (struct classifier_ctx *ctx, statfile_pool_t *pool, const char *sym }; char *value; int nodes, minnodes, iterations = 0; - struct statfile *st, *sel_st; + struct statfile *st, *sel_st = NULL; stat_file_t *sel = NULL, *to_learn; - long double res = 0., max = 0., start_value, end_value; + long double res = 0., max = 0., start_value = 0., end_value = 0.; double learn_threshold = 0.0; GList *cur, *to_demote = NULL; gboolean force_learn = FALSE; @@ -432,6 +432,17 @@ winnow_learn (struct classifier_ctx *ctx, statfile_pool_t *pool, const char *sym } cur = g_list_next (cur); } + + if (sel_st == NULL) { + g_set_error (err, + winnow_error_quark(), /* error domain */ + 1, /* error code */ + "cannot find statfile for symbol %s", + symbol); + msg_err ("cannot find statfile for symbol %s", symbol); + return FALSE; + } + to_learn = statfile_pool_is_open (pool, sel_st->path); if (to_learn == NULL) { g_set_error (err, -- cgit v1.2.3