aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-30 11:32:07 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-30 11:32:07 +0100
commitff463c609bd364a8090d89a52c4878fa1aef93bd (patch)
tree5ef217f37e5f082b1c3aa7537879f586465dec7a
parent56583a05d4f391afc3a7bb1551be9724a6d7ba72 (diff)
downloadrspamd-ff463c609bd364a8090d89a52c4878fa1aef93bd.tar.gz
rspamd-ff463c609bd364a8090d89a52c4878fa1aef93bd.zip
Fix couple of compiler warnings
-rw-r--r--src/client/rspamc.c2
-rw-r--r--src/controller.c2
-rw-r--r--src/fuzzy_storage.c10
-rw-r--r--src/hs_helper.c4
-rw-r--r--src/libcryptobox/poly1305/ref-64.c1
-rw-r--r--src/libserver/dkim.c4
-rw-r--r--src/libserver/symbols_cache.c9
-rw-r--r--src/libserver/url.c2
-rw-r--r--src/libserver/worker_util.c5
-rw-r--r--src/libstat/stat_process.c4
-rw-r--r--src/libutil/aio_event.c6
-rw-r--r--src/libutil/http.c8
-rw-r--r--src/libutil/map.c2
-rw-r--r--src/libutil/rrd.c3
-rw-r--r--src/libutil/str_util.c6
-rw-r--r--src/libutil/util.c2
-rw-r--r--src/lua/lua_cfg_file.c7
-rw-r--r--src/plugins/fuzzy_check.c3
-rw-r--r--src/plugins/regexp.c2
-rw-r--r--src/rspamadm/rspamadm.c11
-rw-r--r--src/rspamd.c3
21 files changed, 62 insertions, 34 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c
index 2782f4d9a..8fcde9662 100644
--- a/src/client/rspamc.c
+++ b/src/client/rspamc.c
@@ -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;
diff --git a/src/controller.c b/src/controller.c
index 29cd1b351..0a9a26e95 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -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;
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index d204a7c2a..12cf14fe2 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -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;
diff --git a/src/hs_helper.c b/src/hs_helper.c
index 771d74d7a..364530313 100644
--- a/src/hs_helper.c
+++ b/src/hs_helper.c
@@ -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
diff --git a/src/libcryptobox/poly1305/ref-64.c b/src/libcryptobox/poly1305/ref-64.c
index db7b85c1e..01b8ff2c1 100644
--- a/src/libcryptobox/poly1305/ref-64.c
+++ b/src/libcryptobox/poly1305/ref-64.c
@@ -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
diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c
index d0691d80b..faf3f0423 100644
--- a/src/libserver/dkim.c
+++ b/src/libserver/dkim.c
@@ -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 {
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index d030e5c9d..5f405420c 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -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;
+ }
}
}
diff --git a/src/libserver/url.c b/src/libserver/url.c
index 90f993874..3bb35ed54 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -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;
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 49b52205b..525a42e73 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -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
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c
index 8de362002..4dd489571 100644
--- a/src/libstat/stat_process.c
+++ b/src/libstat/stat_process.c
@@ -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 "
diff --git a/src/libutil/aio_event.c b/src/libutil/aio_event.c
index 0c3a6f4fb..64070423e 100644
--- a/src/libutil/aio_event.c
+++ b/src/libutil/aio_event.c
@@ -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);
diff --git a/src/libutil/http.c b/src/libutil/http.c
index c05aa9e3b..79a3f317a 100644
--- a/src/libutil/http.c
+++ b/src/libutil/http.c
@@ -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"
diff --git a/src/libutil/map.c b/src/libutil/map.c
index e8fb715b7..0fc201387 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -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;
diff --git a/src/libutil/rrd.c b/src/libutil/rrd.c
index 62a133e48..4a695ad9b 100644
--- a/src/libutil/rrd.c
+++ b/src/libutil/rrd.c
@@ -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;
}
}
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c
index d8e2dab0c..d3851c89c 100644
--- a/src/libutil/str_util.c
+++ b/src/libutil/str_util.c
@@ -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,
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 68366927f..c4f9ef242 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -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
diff --git a/src/lua/lua_cfg_file.c b/src/lua/lua_cfg_file.c
index 0a63164f5..9df0a02ce 100644
--- a/src/lua/lua_cfg_file.c
+++ b/src/lua/lua_cfg_file.c
@@ -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);
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 0030b2cbc..ef5eb1c22 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -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);
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 43b9f9ab1..ceee20f92 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -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;
diff --git a/src/rspamadm/rspamadm.c b/src/rspamadm/rspamadm.c
index 02bdd310f..a170b5830 100644
--- a/src/rspamadm/rspamadm.c
+++ b/src/rspamadm/rspamadm.c
@@ -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},
diff --git a/src/rspamd.c b/src/rspamd.c
index f4bdec1aa..f7ac7a341 100644
--- a/src/rspamd.c
+++ b/src/rspamd.c
@@ -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