]> source.dussan.org Git - rspamd.git/commitdiff
Fix couple of compiler warnings
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 30 Jan 2016 10:32:07 +0000 (11:32 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 30 Jan 2016 10:32:07 +0000 (11:32 +0100)
21 files changed:
src/client/rspamc.c
src/controller.c
src/fuzzy_storage.c
src/hs_helper.c
src/libcryptobox/poly1305/ref-64.c
src/libserver/dkim.c
src/libserver/symbols_cache.c
src/libserver/url.c
src/libserver/worker_util.c
src/libstat/stat_process.c
src/libutil/aio_event.c
src/libutil/http.c
src/libutil/map.c
src/libutil/rrd.c
src/libutil/str_util.c
src/libutil/util.c
src/lua/lua_cfg_file.c
src/plugins/fuzzy_check.c
src/plugins/regexp.c
src/rspamadm/rspamadm.c
src/rspamd.c

index 2782f4d9a32467e558a35c3fbf25abac1e787abd..8fcde9662bb28364bb7e75328fb1c14f2d7b7a13 100644 (file)
@@ -990,7 +990,7 @@ rspamc_mime_output (FILE *out, ucl_object_t *result, GString *input,
        const gchar *action = "no action";
        gchar scorebuf[32];
        GString *symbuf, *folded_symbuf, *added_headers;
-       gint act;
+       gint act = 0;
        goffset headers_pos;
        gdouble score = 0.0, required_score = 0.0;
        gboolean is_spam = FALSE;
index 29cd1b35103aa9ba99aaaef81b28bc92bdbd46cf..0a9a26e95fb1a3258acdf925f4525b54ce55ed4a 100644 (file)
@@ -247,7 +247,7 @@ rspamd_check_encrypted_password (struct rspamd_controller_worker_ctx *ctx,
 {
        const gchar *salt, *hash;
        gchar *salt_decoded, *key_decoded;
-       gsize salt_len, key_len;
+       gsize salt_len = 0, key_len = 0;
        gboolean ret = TRUE;
        guchar *local_key;
        rspamd_ftok_t *cache;
index d204a7c2a5cf54c4c9bbb6bd24e847d37f34686a..12cf14fe229d0c4a56d0299511b1b4863b4db42e 100644 (file)
@@ -393,14 +393,14 @@ static void
 rspamd_fuzzy_process_command (struct fuzzy_session *session)
 {
        gboolean encrypted = FALSE, is_shingle = FALSE;
-       struct rspamd_fuzzy_cmd *cmd;
+       struct rspamd_fuzzy_cmd *cmd = NULL;
        struct rspamd_fuzzy_reply result;
        struct fuzzy_peer_cmd *up_cmd;
        struct fuzzy_peer_request *up_req;
        struct fuzzy_key_stat *ip_stat = NULL;
        rspamd_inet_addr_t *naddr;
        gpointer ptr;
-       gsize up_len;
+       gsize up_len = 0;
 
        switch (session->cmd_type) {
        case CMD_NORMAL:
@@ -425,6 +425,12 @@ rspamd_fuzzy_process_command (struct fuzzy_session *session)
                break;
        }
 
+       if (G_UNLIKELY (cmd == NULL || up_len == 0)) {
+               result.value = 500;
+               result.prob = 0.0;
+               goto reply;
+       }
+
        if (session->ctx->encrypted_only && !encrypted) {
                /* Do not accept unencrypted commands */
                result.value = 403;
index 771d74d7a8619a68cb3ee35b989581899d2b77f2..3645303137a46b796bfc4b04a4e4a2e118fc42cc 100644 (file)
@@ -48,8 +48,8 @@ worker_t hs_helper_worker = {
                SOCK_STREAM                 /* TCP socket */
 };
 
-const static gdouble default_max_time = 1.0;
-const static gdouble default_recompile_time = 60.0;
+static const gdouble default_max_time = 1.0;
+static const gdouble default_recompile_time = 60.0;
 
 /*
  * Worker's context
index db7b85c1e486114df608ef09df4ad935333a470e..01b8ff2c19c7dda3562a3ed56135baebb4790ac2 100644 (file)
@@ -20,6 +20,7 @@ enum {
 
        #define POLY1305_NOINLINE __declspec(noinline)
 #elif defined(__GNUC__)
+       #pragma GCC system_header
        #if defined(__SIZEOF_INT128__)
                typedef unsigned __int128 uint128_t;
        #else
index d0691d80bdbbedf488679b606760a5b7159e0bf9..faf3f04233504096d08d74dceee0e629b33f2776 100644 (file)
@@ -1417,7 +1417,7 @@ rspamd_dkim_canonize_header_simple (rspamd_dkim_context_t *ctx,
        gint state = 0, hlen;
        gboolean found = FALSE;
        GArray *to_sign;
-       struct rspamd_dkim_sign_chunk chunk, *elt;
+       struct rspamd_dkim_sign_chunk chunk, *elt = NULL;
        gint i;
 
        /* This process is very similar to raw headers processing */
@@ -1523,7 +1523,7 @@ rspamd_dkim_canonize_header_simple (rspamd_dkim_context_t *ctx,
                                }
                        }
 
-                       if (elt->append_crlf) {
+                       if (elt && elt->append_crlf) {
                                rspamd_dkim_signature_update (ctx, elt->begin, elt->len + 1);
                        }
                        else {
index d030e5c9d0c082be61b31861ebc8be9bfdf24653..5f405420cf85b96be12dd41b17d9b0d035c9bee8 100644 (file)
@@ -1389,10 +1389,15 @@ rspamd_symbols_cache_resort_cb (gint fd, short what, gpointer ud)
        }
        /* Sync virtual symbols */
        for (i = 0; i < cache->items_by_id->len; i ++) {
+               item = g_ptr_array_index (cache->items_by_id, i);
+
                if (item->parent != -1) {
                        parent = g_ptr_array_index (cache->items_by_id, item->parent);
-                       item->avg_time = parent->avg_time;
-                       item->avg_counter = parent->avg_counter;
+
+                       if (parent) {
+                               item->avg_time = parent->avg_time;
+                               item->avg_counter = parent->avg_counter;
+                       }
                }
        }
 
index 90f9938743b060565d1e421ceabb225051bfde9e..3bb35ed5485a89424e5123065386e6ef2c32a536 100644 (file)
@@ -1119,7 +1119,7 @@ rspamd_url_is_ip (struct rspamd_url *uri, rspamd_mempool_t *pool)
        struct in_addr in4;
        struct in6_addr in6;
        gboolean ret = FALSE, check_num = TRUE;
-       guint32 n, dots, t, i, shift, nshift;
+       guint32 n, dots, t = 0, i = 0, shift, nshift;
 
        p = uri->host;
        end = p + uri->hostlen;
index 49b52205b87b818a3fadf77d10705e23915f1f09..525a42e73b371649a7a8b7f67905673d02cb41f6 100644 (file)
@@ -32,7 +32,7 @@
 #include "rspamd_control.h"
 
 #ifdef WITH_GPERF_TOOLS
-#include <google/profiler.h>
+#include <gperftools/profiler.h>
 #endif
 /* sys/resource.h */
 #ifdef HAVE_SYS_RESOURCE_H
@@ -45,6 +45,9 @@
 #ifdef HAVE_GRP_H
 #include <grp.h>
 #endif
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#endif
 
 /**
  * Return worker's control structure by its type
index 8de3620020309f08eb0b4e4d59844c75941b644f..4dd4895715a2b76961ba5bf3626e063ebfc8c286 100644 (file)
@@ -691,7 +691,7 @@ rspamd_stat_check_autolearn (struct rspamd_task *task)
        struct rspamd_stat_ctx *st_ctx;
        struct rspamd_classifier *cl;
        const ucl_object_t *obj, *elt1, *elt2;
-       struct metric_result *mres;
+       struct metric_result *mres = NULL;
        struct rspamd_task **ptask;
        lua_State *L;
        GString *tb;
@@ -836,7 +836,7 @@ rspamd_stat_check_autolearn (struct rspamd_task *task)
                                        task->flags &= ~(RSPAMD_TASK_FLAG_LEARN_HAM |
                                                        RSPAMD_TASK_FLAG_LEARN_SPAM);
                                }
-                               else {
+                               else if (mres != NULL) {
                                        if (task->flags & RSPAMD_TASK_FLAG_LEARN_HAM) {
                                                msg_info_task ("<%s>: autolearn ham for classifier "
                                                                "'%s' as message's "
index 0c3a6f4fbc363b071d50e13917a640a120d462aa..64070423e3bc5211b1e9b405946daa5433233fad 100644 (file)
@@ -338,12 +338,12 @@ rspamd_aio_read (gint fd,
        rspamd_aio_cb cb,
        gpointer ud)
 {
-       struct io_cbdata *cbdata;
        gint r = -1;
 
        if (ctx->has_aio) {
 #ifdef LINUX
                struct iocb *iocb[1];
+               struct io_cbdata *cbdata;
 
                cbdata = g_slice_alloc (sizeof (struct io_cbdata));
                cbdata->cb = cb;
@@ -382,6 +382,7 @@ rspamd_aio_read (gint fd,
        }
        else {
                /* Blocking variant */
+               goto blocking;
 blocking:
 #ifdef _LARGEFILE64_SOURCE
                r = lseek64 (fd, offset, SEEK_SET);
@@ -414,12 +415,12 @@ rspamd_aio_write (gint fd,
        rspamd_aio_cb cb,
        gpointer ud)
 {
-       struct io_cbdata *cbdata;
        gint r = -1;
 
        if (ctx->has_aio) {
 #ifdef LINUX
                struct iocb *iocb[1];
+               struct io_cbdata *cbdata;
 
                cbdata = g_slice_alloc (sizeof (struct io_cbdata));
                cbdata->cb = cb;
@@ -462,6 +463,7 @@ rspamd_aio_write (gint fd,
        }
        else {
                /* Blocking variant */
+               goto blocking;
 blocking:
 #ifdef _LARGEFILE64_SOURCE
                r = lseek64 (fd, offset, SEEK_SET);
index c05aa9e3b744c1271fa95cb40e4609bad66ce0b7..79a3f317add684870352fc5f90d17c7dc8a2ce57 100644 (file)
@@ -173,10 +173,8 @@ rspamd_http_parse_date (const gchar *header, gsize len)
                end = header + strlen (header);
        }
 
-#if (NGX_SUPPRESS_WARN)
        day = 32;
        year = 2038;
-#endif
 
        for (p = header; p < end; p++) {
                if (*p == ',') {
@@ -1348,8 +1346,8 @@ rspamd_http_connection_write_message (struct rspamd_http_connection *conn,
        struct rspamd_http_header *hdr;
        struct tm t, *ptm;
        gchar datebuf[64], repbuf[512], *pbody;
-       gint i, hdrcount, meth_len, preludelen = 0;
-       gsize bodylen, enclen;
+       gint i, hdrcount, meth_len = 0, preludelen = 0;
+       gsize bodylen, enclen = 0;
        rspamd_fstring_t *buf;
        gboolean encrypted = FALSE;
        gchar *b32_key, *b32_id;
@@ -1542,7 +1540,7 @@ rspamd_http_connection_write_message (struct rspamd_http_connection *conn,
                                                enclen);
                        }
                        else {
-                               rspamd_printf_fstring (&buf, "HTTP/1.1 %d %V\r\n"
+                               meth_len = rspamd_printf_fstring (&buf, "HTTP/1.1 %d %V\r\n"
                                                "Connection: close\r\n"
                                                "Server: %s\r\n"
                                                "Date: %s\r\n"
index e8fb715b72aa5cee2c5852bd2d8cf72de03163f5..0fc201387d31d06da3d2eb54dab0715c927d86ba 100644 (file)
@@ -246,7 +246,7 @@ static void
 read_map_file (struct rspamd_map *map, struct file_map_data *data)
 {
        struct map_cb_data cbdata;
-       gchar buf[BUFSIZ], *remain;
+       gchar buf[BUFSIZ], *remain = NULL;
        ssize_t r;
        gint fd, rlen, tlen;
        rspamd_mempool_t *pool = map->pool;
index 62a133e48def0d3fa67d5110d4ce518122059feb..4a695ad9bcbe40057d330b476cc65d598ff071f9 100644 (file)
@@ -865,7 +865,7 @@ rspamd_rrd_update_cdp (struct rspamd_rrd_file *file,
        struct rrd_rra_def *rra;
        rrd_value_t *scratch;
        enum rrd_cf_type cf;
-       gdouble last_cdp, cur_cdp;
+       gdouble last_cdp = INFINITY, cur_cdp = INFINITY;
        gulong pdp_in_cdp;
 
        rra = &file->rra_def[rra_index];
@@ -927,6 +927,7 @@ rspamd_rrd_update_cdp (struct rspamd_rrd_file *file,
                                        case RRD_CF_LAST:
                                        default:
                                                scratch[CDP_primary_val].dv = pdp_temp[i];
+                                               last_cdp = INFINITY;
                                                break;
                                        }
                                }
index d8e2dab0c3799e55ef0e16a14ce9e98c0ae486d5..d3851c89c4457b3884d3588f2ca29a32e4a93882 100644 (file)
@@ -919,11 +919,11 @@ rspamd_header_value_fold (const gchar *name,
        const gchar *p, *c;
        gboolean first_token = TRUE;
        enum {
-               fold_before,
+               fold_before = 0,
                fold_after
-       } fold_type;
+       } fold_type = fold_before;
        enum {
-               read_token,
+               read_token = 0,
                read_quoted,
                after_quote,
                fold_token,
index 68366927ff69fd30c61be19df310ecd29d5b45cf..c4f9ef2423423b9175053aca8b802c52de676d93 100644 (file)
@@ -57,7 +57,7 @@
 #include <mach/mach_time.h>
 #endif
 #ifdef WITH_GPERF_TOOLS
-#include <google/profiler.h>
+#include <gperftools/profiler.h>
 #endif
 /* poll */
 #ifdef HAVE_POLL_H
index 0a63164f59a790a58f44aa17ca26dbb1c1382c5d..9df0a02ce97c5ca6e257619b61291cfd6b5fef67 100644 (file)
@@ -40,7 +40,7 @@ lua_process_metric (lua_State *L, const gchar *name, struct rspamd_config *cfg)
 {
        GList *metric_list;
        gchar *symbol;
-       const gchar *desc;
+       const gchar *desc = NULL;
        struct metric *metric;
        gdouble *score;
        struct rspamd_symbol_def *s;
@@ -74,7 +74,6 @@ lua_process_metric (lua_State *L, const gchar *name, struct rspamd_config *cfg)
                                lua_gettable (L, -2);
                                if (lua_isstring (L, -1)) {
                                        desc = lua_tostring (L, -1);
-                                       s->description = rspamd_mempool_strdup (cfg->cfg_pool, desc);
                                }
                                lua_pop (L, 1);
                        }
@@ -103,6 +102,10 @@ lua_process_metric (lua_State *L, const gchar *name, struct rspamd_config *cfg)
                                g_hash_table_insert (metric->symbols, symbol, s);
                        }
 
+                       if (desc) {
+                               s->description = rspamd_mempool_strdup (cfg->cfg_pool, desc);
+                       }
+
                        if ((metric_list =
                                g_hash_table_lookup (cfg->metrics_symbols, symbol)) == NULL) {
                                metric_list = g_list_prepend (NULL, metric);
index 0030b2cbc93870a89abb2316ab21b85e9bb3f6fe..ef5eb1c2206f2047274c4ffc5b85ef171fea3f5a 100644 (file)
@@ -1091,7 +1091,7 @@ fuzzy_cmd_from_data_part (struct fuzzy_rule *rule,
                gsize datalen)
 {
        struct rspamd_fuzzy_cmd *cmd;
-       struct rspamd_fuzzy_encrypted_cmd *enccmd;
+       struct rspamd_fuzzy_encrypted_cmd *enccmd = NULL;
        struct fuzzy_cmd_io *io;
        rspamd_cryptobox_hash_state_t st;
 
@@ -1121,6 +1121,7 @@ fuzzy_cmd_from_data_part (struct fuzzy_rule *rule,
        io->tag = cmd->tag;
 
        if (rule->peer_key) {
+               g_assert (enccmd != NULL);
                fuzzy_encrypt_cmd (rule, &enccmd->hdr, (guchar *) cmd, sizeof (*cmd));
                io->io.iov_base = enccmd;
                io->io.iov_len = sizeof (*enccmd);
index 43b9f9ab10648b4823aa191c5ce57cd388cf2d99..ceee20f9228b1ad72a9d8ee61854471b4264a214 100644 (file)
@@ -128,7 +128,7 @@ regexp_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
 gint
 regexp_module_config (struct rspamd_config *cfg)
 {
-       struct regexp_module_item *cur_item;
+       struct regexp_module_item *cur_item = NULL;
        const ucl_object_t *sec, *value, *elt;
        ucl_object_iter_t it = NULL;
        gint res = TRUE, id, nre = 0, nlua = 0;
index 02bdd310f8b5fc1d4d3ced651c9e44fa9e6c5919..a170b58308f9374b47c2a35951c925398212f589 100644 (file)
@@ -55,12 +55,21 @@ static gboolean rspamadm_parse_ucl_var (const gchar *option_name,
                const gchar *value, gpointer data,
                GError **error);
 
+static union {
+       gboolean (*func)(const gchar *option_name,
+                                       const gchar *value, gpointer data,
+                                       GError **error);
+       const gpointer ptr;
+} rspamadm_parse_ucl_var_un = {
+       .func = &rspamadm_parse_ucl_var
+};
+
 static GOptionEntry entries[] = {
        {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
                        "Enable verbose logging", NULL},
        {"list-commands", 'l', 0, G_OPTION_ARG_NONE, &list_commands,
                        "List available commands", NULL},
-       {"var", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer)rspamadm_parse_ucl_var,
+       {"var", 0, 0, G_OPTION_ARG_CALLBACK, &rspamadm_parse_ucl_var_un,
                        "Redefine UCL variable", NULL},
        {"help", 'h', 0, G_OPTION_ARG_NONE, &show_help,
                        "Show help", NULL},
index f4bdec1aa537db7ceb3a838e572e9c83ba7369c3..f7ac7a3415731173e55706dadf49d29ee63ffd66 100644 (file)
@@ -57,9 +57,8 @@
 #include <libutil.h>
 #endif
 #ifdef WITH_GPERF_TOOLS
-#include <google/profiler.h>
+#include <gperftools/profiler.h>
 #endif
-
 #ifdef HAVE_STROPS_H
 #include <stropts.h>
 #endif