aboutsummaryrefslogtreecommitdiffstats
path: root/src/classifiers
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2010-10-11 18:39:56 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2010-10-11 18:39:56 +0400
commitdbee2f63ee747b5d4247038f27566bc5aebfe3b7 (patch)
treec2d60701691ab106e593be24a6974ab7dc0e6fa1 /src/classifiers
parentb0ce5fefb9e694083846af1e45b09f4baa4b0446 (diff)
downloadrspamd-dbee2f63ee747b5d4247038f27566bc5aebfe3b7.tar.gz
rspamd-dbee2f63ee747b5d4247038f27566bc5aebfe3b7.zip
Fixes bugs found with clang-static analyser.
Strictly follow c99 standart. Turn on pedantic c99 checks.
Diffstat (limited to 'src/classifiers')
-rw-r--r--src/classifiers/bayes.c1
-rw-r--r--src/classifiers/winnow.c15
2 files changed, 14 insertions, 2 deletions
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,