]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix compile warnings
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 10 Oct 2019 16:17:09 +0000 (17:17 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 10 Oct 2019 16:17:09 +0000 (17:17 +0100)
22 files changed:
contrib/lua-lpeg/lptypes.h
contrib/lua-lpeg/lpvm.c
src/controller.c
src/libcryptobox/catena/catena.c
src/libmime/message.c
src/libmime/mime_headers.c
src/libserver/html.c
src/libserver/spf.c
src/libserver/task.c
src/libutil/http_context.c
src/libutil/map.c
src/libutil/printf.c
src/libutil/ssl_util.c
src/libutil/util.c
src/lua/lua_common.c
src/lua/lua_cryptobox.c
src/lua/lua_task.c
src/lua/lua_udp.c
src/lua/lua_worker.c
src/plugins/dkim_check.c
src/plugins/regexp.c
src/rspamadm/lua_repl.c

index 7173d11d3ada3206550d47633aef37ff4655b812..9dee116cd516e6e076442bd67a94e2b02b56b9f9 100644 (file)
@@ -154,9 +154,9 @@ typedef struct Charset {
 /* Special workaround for luajit */
 #if defined(WITH_LUAJIT) && !(defined(_X86_) || defined(__x86_64__) || defined(__i386__))
 # define LPEG_LUD_WORKAROUND 1
-#endif
 void * lpeg_allocate_mem_low(size_t sz);
 void lpeg_free_mem_low(void *p);
+#endif
 
 #endif
 
index 4417128268987805fd62582000118da25f71b02f..4ef4245793f0aa4d109abb02e9c2a75c4e3731ef 100644 (file)
@@ -17,6 +17,7 @@
 #include "lpvm.h"
 #include "lpprint.h"
 
+#ifdef LPEG_LUD_WORKAROUND
 #include <sys/mman.h>
 
 #define MAX_PIECES (1u << 2u)
@@ -119,6 +120,8 @@ lpeg_free_mem_low(void *p)
        /* No match, unmapped by allocation */
 }
 
+#endif
+
 /* initial size for call/backtrack stack */
 #if !defined(INITBACK)
 #define INITBACK       MAXBACK
index 33273772454226141cc7fcafe77f3cce0faaef4f..6e16beb915b2e25077829fc4c3df511eed3e2ec1 100644 (file)
@@ -105,8 +105,8 @@ INIT_LOG_MODULE(controller)
 #define COLOR_REJECT "#CB4B4B"
 #define COLOR_TOTAL "#9440ED"
 
-const static ev_tstamp rrd_update_time = 1.0;
-const static guint64 rspamd_controller_ctx_magic = 0xf72697805e6941faULL;
+static const ev_tstamp rrd_update_time = 1.0;
+static const guint64 rspamd_controller_ctx_magic = 0xf72697805e6941faULL;
 
 extern void fuzzy_stat_command (struct rspamd_task *task);
 
index 5b1da3129231b00860b7069aed96eb7275c8aa79..0a3ab248adc4152433f91d7258d9b97f9e0a6b79 100644 (file)
@@ -217,8 +217,8 @@ initmem (const uint8_t x[H_LEN], const uint64_t c, uint8_t *r)
 }
 
 static inline void
-gamma (const uint8_t garlic, const uint8_t *salt,
-               const uint8_t saltlen, uint8_t *r)
+catena_gamma (const uint8_t garlic, const uint8_t *salt,
+                         const uint8_t saltlen, uint8_t *r)
 {
        const uint64_t q = UINT64_C(1) << ((3 * garlic + 3) / 4);
 
@@ -314,7 +314,7 @@ Flap (const uint8_t x[H_LEN], const uint8_t lambda, const uint8_t garlic,
        initmem (x, c, r);
 
        /*Gamma Function*/
-       gamma (garlic, salt, saltlen, r);
+       catena_gamma (garlic, salt, saltlen, r);
 
        /* DBH */
        for (k = 0; k < lambda; k++) {
index a450f67feb7ae7aaf0e35d79d6995c6fc2fd2864..6a5b4095fc7af022f824e42f960b3e12c7f4d79c 100644 (file)
@@ -224,7 +224,6 @@ rspamd_strip_newlines_parse (struct rspamd_task *task,
                struct rspamd_mime_text_part *part)
 {
        const gchar *p = begin, *c = begin;
-       gchar last_c = '\0';
        gboolean crlf_added = FALSE;
        gboolean url_open_bracket = FALSE;
        UChar32 uc;
@@ -276,7 +275,6 @@ rspamd_strip_newlines_parse (struct rspamd_task *task,
                        case normal_char:
                                state = seen_cr;
                                if (p > c) {
-                                       last_c = *(p - 1);
                                        g_byte_array_append (part->utf_stripped_content,
                                                        (const guint8 *)c, p - c);
                                }
@@ -315,7 +313,6 @@ rspamd_strip_newlines_parse (struct rspamd_task *task,
                                state = seen_lf;
 
                                if (p > c) {
-                                       last_c = *(p - 1);
                                        g_byte_array_append (part->utf_stripped_content,
                                                        (const guint8 *)c, p - c);
                                }
index be3ffc7d0321bff7d9cd6a1714c8e4f6b5998800..b024bd7b148398f0872a72999361465e2d6677a0 100644 (file)
@@ -1415,11 +1415,11 @@ rspamd_smtp_received_process_from (struct rspamd_task *task,
                 * - hostname ([ip]:port helo=xxx)
                 * Maybe more...
                 */
-               gboolean seen_ip_in_data = FALSE, seen_rdns_in_comment = FALSE;
+               gboolean seen_ip_in_data = FALSE;
 
                if (rpart->head_comment && rpart->head_comment->dlen > 0) {
                        /* We can have info within comment as part of RFC */
-                       seen_rdns_in_comment = rspamd_smtp_received_process_host_tcpinfo (
+                       rspamd_smtp_received_process_host_tcpinfo (
                                        task, rh,
                                        rpart->head_comment->data, rpart->head_comment->dlen);
                }
index 73bf054406602b96d97cb58679470f735007efb5..dbbefd10ce6012aa0b587b17c31cead7f115bec0 100644 (file)
@@ -573,7 +573,7 @@ rspamd_html_url_is_phished (rspamd_mempool_t *pool,
        struct rspamd_url **ptext_url)
 {
        struct rspamd_url *text_url;
-       rspamd_ftok_t phished_tld, disp_tok, href_tok;
+       rspamd_ftok_t disp_tok, href_tok;
        gint rc;
        goffset url_pos;
        gchar *url_str = NULL, *idn_hbuf;
@@ -719,8 +719,6 @@ rspamd_html_url_is_phished (rspamd_mempool_t *pool,
                                        if (!rspamd_url_is_subdomain (&disp_tok, &href_tok)) {
                                                href_url->flags |= RSPAMD_URL_FLAG_PHISHED;
                                                href_url->phished_url = text_url;
-                                               phished_tld.begin = href_tok.begin;
-                                               phished_tld.len = href_tok.len;
                                                text_url->flags |= RSPAMD_URL_FLAG_HTML_DISPLAYED;
                                        }
                                }
index 02041b015aa379ba703cc425d8bc2e019839096e..6315948086b1d986cdb3ffac8c01322cede5ebbf 100644 (file)
@@ -1937,7 +1937,6 @@ parse_spf_record (struct spf_record *rec, struct spf_resolved_element *resolved,
        struct spf_addr *addr = NULL;
        gboolean res = FALSE;
        const gchar *begin;
-       struct rspamd_task *task;
        gchar t;
 
        g_assert (elt != NULL);
@@ -1947,7 +1946,6 @@ parse_spf_record (struct spf_record *rec, struct spf_resolved_element *resolved,
                return TRUE;
        }
 
-       task = rec->task;
        begin = expand_spf_macro (rec, resolved, elt);
        addr = rspamd_spf_new_addr (rec, resolved, begin);
        g_assert (addr != NULL);
index e2fcdb2d6beadfe72df40764a1077fce18ea5e85..a4534290726cc3b57fddc8e94e4dad00c5a12dda 100644 (file)
@@ -1059,7 +1059,6 @@ rspamd_task_log_metric_res (struct rspamd_task *task,
        GPtrArray *sorted_symbols;
        struct rspamd_action *act;
        struct rspamd_symbols_group *gr;
-       gdouble gr_score;
        guint i, j;
        khiter_t k;
 
@@ -1157,7 +1156,7 @@ rspamd_task_log_metric_res (struct rspamd_task *task,
                        symbuf = rspamd_fstring_sized_new (128);
                        sorted_symbols = g_ptr_array_sized_new (kh_size (mres->sym_groups));
 
-                       kh_foreach (mres->sym_groups, gr, gr_score,{
+                       kh_foreach_key (mres->sym_groups, gr,{
                                if (!(gr->flags & RSPAMD_SYMBOL_GROUP_PUBLIC)) {
                                        if (lf->type == RSPAMD_LOG_PUBLIC_GROUPS) {
                                                continue;
index 9e2b097980b2e3a8ec5055a1581aa085e81fbe4b..4d701d0c5190256bd1de1fe7f9d6594082fec17f 100644 (file)
@@ -468,14 +468,11 @@ static void
 rspamd_http_keepalive_handler (gint fd, short what, gpointer ud)
 {
        struct rspamd_http_keepalive_cbdata *cbdata =
-                       (struct rspamd_http_keepalive_cbdata *)ud;
-       struct rspamd_http_context *ctx;
-       /*
+                       (struct rspamd_http_keepalive_cbdata *)ud;/*
         * We can get here if a remote side reported something or it has
         * timed out. In both cases we just terminate keepalive connection.
         */
 
-       ctx = cbdata->ctx;
        g_queue_delete_link (cbdata->queue, cbdata->link);
        msg_debug_http_context ("remove keepalive element %s (%s), %d connections left",
                        rspamd_inet_address_to_string_pretty (cbdata->conn->keepalive_hash_key->addr),
index 42134921aee474fbec19491e32a2bb183df605de..123d31c5f5117340491f769a06235a74e1e69e5d 100644 (file)
@@ -75,9 +75,7 @@ write_http_request (struct http_callback_data *cbd)
 {
        gchar datebuf[128];
        struct rspamd_http_message *msg;
-       struct rspamd_map *map;
 
-       map = cbd->map;
        msg = rspamd_http_new_message (HTTP_REQUEST);
 
        if (cbd->bk->protocol == MAP_PROTO_HTTPS) {
index b0229c73a7c9216cc13e72275c04dd8cabc1baf5..972d34e82593c1617a56c524b9fed410c801fc65 100644 (file)
@@ -593,7 +593,7 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
 {
        gchar zero, numbuf[G_ASCII_DTOSTR_BUF_SIZE], dtoabuf[32], *p, *last;
        guchar c;
-       const gchar *buf_start = fmt, *fmt_start = NULL;
+       const gchar *buf_start = fmt;
        gint d;
        gdouble f;
        glong written = 0, wr, slen;
@@ -623,8 +623,6 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
                                written += wr;
                        }
 
-                       fmt_start = fmt;
-
                        i64 = 0;
                        ui64 = 0;
 
index 32778f265a8553369af6050837a6815c7731f8f8..6bd7a19861fb8c816489b8e5b29146a2ec8ddd21 100644 (file)
@@ -579,7 +579,6 @@ rspamd_ssl_connect_fd (struct rspamd_ssl_connection *conn, gint fd,
                gpointer handler_data)
 {
        gint ret;
-       short what;
 
        g_assert (conn != NULL);
 
@@ -630,11 +629,9 @@ rspamd_ssl_connect_fd (struct rspamd_ssl_connection *conn, gint fd,
 
                if (ret == SSL_ERROR_WANT_READ) {
                        msg_debug_ssl ("not connected, want read");
-                       what = EV_READ;
                }
                else if (ret == SSL_ERROR_WANT_WRITE) {
                        msg_debug_ssl ("not connected, want write");
-                       what = EV_WRITE;
                }
                else {
                        conn->shut = ssl_shut_unclean;
index f528a321edbf692fa58e43cc76bb047fef677c51..55696c212c39958b608c47570bc651c60866b5b8 100644 (file)
@@ -786,7 +786,7 @@ rspamd_pass_signal (GHashTable * workers, gint signo)
 #ifndef HAVE_SETPROCTITLE
 
 #ifdef LINUX
-static gchar *title_buffer = 0;
+static gchar *title_buffer = NULL;
 static size_t title_buffer_size = 0;
 static gchar *title_progname, *title_progname_full;
 #endif
@@ -1076,7 +1076,6 @@ setproctitle (const gchar *fmt, ...)
        ssize_t written;
 
        if (fmt) {
-               ssize_t written2;
                va_list ap;
 
                written = rspamd_snprintf (title_buffer,
@@ -1087,13 +1086,11 @@ setproctitle (const gchar *fmt, ...)
                        return -1;
 
                va_start (ap, fmt);
-               written2 = rspamd_vsnprintf (title_buffer + written,
+               rspamd_vsnprintf (title_buffer + written,
                                title_buffer_size - written,
                                fmt,
                                ap);
                va_end (ap);
-               if (written2 < 0 || (size_t) written2 >= title_buffer_size - written)
-                       return -1;
        }
        else {
                written = rspamd_snprintf (title_buffer,
index bbcec4c1ce02be99bbbb184938533ba45dd3ec01..d68e8e952b5dc6a147700549850d5b939368490b 100644 (file)
@@ -253,11 +253,9 @@ rspamd_lua_set_path (lua_State *L, const ucl_object_t *cfg_obj, GHashTable *vars
 {
        const gchar *old_path, *additional_path = NULL;
        const ucl_object_t *opts = NULL;
-       const gchar *pluginsdir = RSPAMD_PLUGINSDIR,
-                       *rulesdir = RSPAMD_RULESDIR,
+       const gchar *rulesdir = RSPAMD_RULESDIR,
                        *lualibdir = RSPAMD_LUALIBDIR,
-                       *libdir = RSPAMD_LIBDIR,
-                       *sharedir = RSPAMD_SHAREDIR;
+                       *libdir = RSPAMD_LIBDIR;
        const gchar *t;
 
        gchar path_buf[PATH_MAX];
@@ -290,16 +288,6 @@ rspamd_lua_set_path (lua_State *L, const ucl_object_t *cfg_obj, GHashTable *vars
        }
        else {
                /* Try environment */
-               t = getenv ("SHAREDIR");
-               if (t) {
-                       sharedir = t;
-               }
-
-               t = getenv ("PLUGINSDIR");
-               if (t) {
-                       pluginsdir = t;
-               }
-
                t = getenv ("RULESDIR");
                if (t) {
                        rulesdir = t;
@@ -321,16 +309,6 @@ rspamd_lua_set_path (lua_State *L, const ucl_object_t *cfg_obj, GHashTable *vars
                }
 
                if (vars) {
-                       t = g_hash_table_lookup (vars, "PLUGINSDIR");
-                       if (t) {
-                               pluginsdir = t;
-                       }
-
-                       t = g_hash_table_lookup (vars, "SHAREDIR");
-                       if (t) {
-                               sharedir = t;
-                       }
-
                        t = g_hash_table_lookup (vars, "RULESDIR");
                        if (t) {
                                rulesdir = t;
index 645b2495fc90dced44d3c6c0ea7880e9c6b19fb2..518ae9389fa37d994f740a0cdd7d363bb242c2ff 100644 (file)
@@ -2321,6 +2321,16 @@ lua_cryptobox_gen_dkim_keypair (lua_State *L)
 
                /* Process private key */
                rc = i2d_RSAPrivateKey_bio (mbio, r);
+
+               if (rc == 0) {
+                       BIO_free (mbio);
+                       BN_free (e);
+                       RSA_free (r);
+                       EVP_PKEY_free (pk);
+
+                       return luaL_error (L, "i2d_RSAPrivateKey_bio failed");
+               }
+
                len = BIO_get_mem_data (mbio, &data);
 
                b64_data = rspamd_encode_base64 (data, len, -1, &b64_len);
@@ -2334,6 +2344,16 @@ lua_cryptobox_gen_dkim_keypair (lua_State *L)
                /* Process public key */
                BIO_reset (mbio);
                rc = i2d_RSA_PUBKEY_bio (mbio, r);
+
+               if (rc == 0) {
+                       BIO_free (mbio);
+                       BN_free (e);
+                       RSA_free (r);
+                       EVP_PKEY_free (pk);
+
+                       return luaL_error (L, "i2d_RSA_PUBKEY_bio failed");
+               }
+
                len = BIO_get_mem_data (mbio, &data);
 
                b64_data = rspamd_encode_base64 (data, len, -1, &b64_len);
index 2ec6dc29b66ab42a9e2d22e2a8d75c4d5f015e1e..b04596ed3530eac51f0f1f85e1847d7d3b60df2c 100644 (file)
@@ -3510,6 +3510,7 @@ lua_task_has_from (lua_State *L)
        }
 
        lua_pushboolean (L, ret);
+       (void)nrcpt; /* Silence warning */
 
        return 1;
 }
@@ -5705,12 +5706,9 @@ lua_task_get_metric_action (lua_State *L)
 {
        LUA_TRACE_POINT;
        struct rspamd_task *task = lua_check_task (L, 1);
-       struct rspamd_scan_result *metric_res;
        struct rspamd_action *action;
 
        if (task) {
-               metric_res = task->result;
-
                action = rspamd_check_action_metric (task);
                lua_pushstring (L, action->name);
        }
index b72108c34e3ea1c8b4e04de689031af2dfc6fe56..5d1fd8c62e273acdb0e3e2c46c7803d1efed8ac2 100644 (file)
@@ -256,11 +256,8 @@ static void
 lua_udp_io_handler (gint fd, short what, gpointer p)
 {
        struct lua_udp_cbdata *cbd = (struct lua_udp_cbdata *)p;
-       lua_State *L;
        gssize r;
 
-       L = cbd->L;
-
        if (what == EV_TIMEOUT) {
                if (cbd->sent && cbd->retransmits > 0) {
                        r = lua_try_send_request (cbd);
index eaf0e02d7db003db17288b8dc61f7dd8157fddd4..940c6ae4add4ef08d336c5aae77ee2a22eb0a223 100644 (file)
@@ -261,9 +261,7 @@ lua_worker_control_fin_session (void *ud)
        struct rspamd_control_reply rep;
        struct rspamd_control_cbdata *cbd = (struct rspamd_control_cbdata *)ud;
        rspamd_mempool_t *pool;
-       lua_State *L;
 
-       L = cbd->L;
        pool = cbd->pool;
 
        memset (&rep, 0, sizeof (rep));
index 4e5eeda7113b66c16e02042bc17eb91e120272eb..410a38309482d219691f0c8448ded47c1007cb7c 100644 (file)
@@ -866,7 +866,8 @@ lua_dkim_sign_handler (lua_State *L)
                                rspamd_mempool_set_variable (task->task_pool, "dkim-signature",
                                                sigs, dkim_module_free_list);
                        } else {
-                               (void) g_list_append (sigs, hdr);
+                               sigs = g_list_append (sigs, hdr);
+                               (void)sigs;
                        }
                }
 
index 6841e452a283294b849405e25b6762d4e03a434c..1b6e0f3f2ee3989a31d7b6c3435862517689b7ae 100644 (file)
@@ -136,7 +136,7 @@ regexp_module_config (struct rspamd_config *cfg)
        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, nshots = cfg->default_max_shots;
+       gint res = TRUE, nre = 0, nlua = 0, nshots = cfg->default_max_shots;
 
        if (!rspamd_config_is_module_enabled (cfg, "regexp")) {
                return TRUE;
@@ -272,7 +272,7 @@ regexp_module_config (struct rspamd_config *cfg)
                                        }
                                }
 
-                               id = rspamd_symcache_add_symbol (cfg->cache,
+                               rspamd_symcache_add_symbol (cfg->cache,
                                                cur_item->symbol,
                                                0,
                                                process_regexp_item,
index b7fd9a4d3c52dc3edb852eb11ae4d94d3dd82f66..ee22c4868d7e503af198b79410a6f26fc14a89f0 100644 (file)
@@ -544,7 +544,7 @@ lua_syntax_highlighter (const char *str, ReplxxColor *colours, int size, void *u
                         * 3 - line num (int), always 1...
                         * 4 - column num (must be less than size)
                         */
-                       const gchar *what, *text;
+                       const gchar *what;
                        gsize column, tlen, cur_top, elt_pos;
                        ReplxxColor elt_color = REPLXX_COLOR_DEFAULT;
 
@@ -554,7 +554,7 @@ lua_syntax_highlighter (const char *str, ReplxxColor *colours, int size, void *u
                        lua_rawgeti (L, elt_pos, 1);
                        what = lua_tostring (L, -1);
                        lua_rawgeti (L, elt_pos, 2);
-                       text = lua_tolstring (L, -1, &tlen);
+                       lua_tolstring (L, -1, &tlen);
                        lua_rawgeti (L, elt_pos, 4);
                        column = lua_tointeger (L, -1);
 
@@ -782,15 +782,11 @@ rspamadm_lua_handle_exec (struct rspamd_http_connection_entry *conn_ent,
        GString *tb;
        gint err_idx, i;
        lua_State *L;
-       struct rspamadm_lua_repl_context *ctx;
-       struct rspamadm_lua_repl_session *session = conn_ent->ud;
        ucl_object_t *obj, *elt;
        const gchar *body;
        gsize body_len;
-
-       ctx = session->ctx;
-
        struct thread_entry *thread = lua_thread_pool_get_for_config (rspamd_main->cfg);
+
        L = thread->lua_state;
 
        body = rspamd_http_message_get_body (msg, &body_len);