]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Some fixes towards epsilon comparison
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 15 Oct 2018 17:05:46 +0000 (18:05 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 15 Oct 2018 17:05:46 +0000 (18:05 +0100)
src/libmime/filter.c

index d2b5492519e78779524fdbd1e2fdfa651496d33b..5f47a5c6a2eb155d7166454814a3df5c5dfd1491 100644 (file)
@@ -152,6 +152,10 @@ rspamd_check_group_score (struct rspamd_task *task,
        return w;
 }
 
+#ifndef DBL_EPSILON
+#define DBL_EPSILON 2.2204460492503131e-16
+#endif
+
 static struct rspamd_symbol_result *
 insert_metric_result (struct rspamd_task *task,
                const gchar *symbol,
@@ -361,21 +365,17 @@ insert_metric_result (struct rspamd_task *task,
                }
 
                if (!isnan (final_score)) {
-#ifndef DBL_EPSILON
-#define DBL_EPSILON 2.2204460492503131e-16
-#endif
                        const double epsilon = DBL_EPSILON;
 
                        metric_res->score += final_score;
                        metric_res->grow_factor = next_gf;
                        s->score = final_score;
 
-                       /* We ignore zero scored symbols */
                        if (final_score > epsilon) {
                                metric_res->npositive ++;
                                metric_res->positive_score += final_score;
                        }
-                       else if (final_score < epsilon) {
+                       else if (final_score < -epsilon) {
                                metric_res->nnegative ++;
                                metric_res->negative_score += fabs (final_score);
                        }