From a93fbccaea8bcec71180add91cf9957dda2a1954 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 22 Nov 2016 17:39:46 +0000 Subject: [PATCH] [Fix] Fix various warnings and issues --- src/controller.c | 2 +- src/libserver/cfg_utils.c | 4 ++-- src/libstat/backends/mmaped_file.c | 6 +----- src/libstat/stat_process.c | 2 +- src/libutil/radix.c | 4 ++-- src/libutil/regexp.c | 2 +- src/libutil/sqlite_utils.c | 4 ++-- src/log_helper.c | 4 ++-- src/plugins/dkim_check.c | 2 +- src/plugins/fuzzy_check.c | 3 ++- src/rspamadm/fuzzy_convert.c | 2 +- src/rspamadm/signtool.c | 6 ++++-- 12 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/controller.c b/src/controller.c index 1eeab1fc4..36261674c 100644 --- a/src/controller.c +++ b/src/controller.c @@ -1500,7 +1500,7 @@ rspamd_controller_handle_lua (struct rspamd_http_connection_entry *conn_ent, } rspamd_snprintf (filebuf, sizeof (filebuf), "%s%c%T", - ctx->static_files_dir, G_DIR_SEPARATOR, lookup); + ctx->static_files_dir, G_DIR_SEPARATOR, &lookup); if (realpath (filebuf, realbuf) == NULL || lstat (realbuf, &st) == -1) { diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 1ca900f4c..fb028cced 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -1271,11 +1271,11 @@ rspamd_check_module (struct rspamd_config *cfg, module_t *mod) if (mod != NULL) { if (mod->module_version != RSPAMD_CUR_MODULE_VERSION) { msg_err_config ("module %s has incorrect version %xd (%xd expected)", - mod->name, mod->module_version, RSPAMD_CUR_MODULE_VERSION); + mod->name, (gint)mod->module_version, RSPAMD_CUR_MODULE_VERSION); ret = FALSE; } if (ret && mod->rspamd_version != RSPAMD_VERSION_NUM) { - msg_err_config ("module %s has incorrect rspamd version %xd (%xd expected)", + msg_err_config ("module %s has incorrect rspamd version %xL (%xL expected)", mod->name, mod->rspamd_version, RSPAMD_VERSION_NUM); ret = FALSE; } diff --git a/src/libstat/backends/mmaped_file.c b/src/libstat/backends/mmaped_file.c index 582818f27..50a635432 100644 --- a/src/libstat/backends/mmaped_file.c +++ b/src/libstat/backends/mmaped_file.c @@ -564,10 +564,6 @@ rspamd_mmaped_file_open (rspamd_mempool_t *pool, { struct stat st; rspamd_mmaped_file_t *new_file; - struct timespec sleep_ts = { - .tv_sec = 0, - .tv_nsec = 1000000 - }; gchar *lock; gint lock_fd; @@ -576,7 +572,7 @@ rspamd_mmaped_file_open (rspamd_mempool_t *pool, if (lock_fd == -1) { msg_info_pool ("cannot open file %s, it is locked by another process", - filename, strerror (errno), errno); + filename); return NULL; } diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 6bd1c4e2a..09f7b8a36 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -135,7 +135,7 @@ rspamd_stat_tokenize_parts_metadata (struct rspamd_stat_ctx *st_ctx, if (part->content && part->content->len > 1) { rspamd_snprintf (tmpbuf, sizeof (tmpbuf), "mime%d:%dlog", - (gint)log2 (part->content->len)); + i, (gint)log2 (part->content->len)); elt.begin = rspamd_mempool_strdup (task->task_pool, tmpbuf); elt.len = strlen (elt.begin); g_array_append_val (ar, elt); diff --git a/src/libutil/radix.c b/src/libutil/radix.c index ac6938fe2..fcc6b1cf6 100644 --- a/src/libutil/radix.c +++ b/src/libutil/radix.c @@ -88,13 +88,13 @@ radix_insert_compressed (radix_compressed_t * tree, msg_err_radix ("cannot insert %p, key: %s/%d, duplicate value", (gpointer)value, inet_ntop (AF_INET, key, ip_str, sizeof (ip_str) - 1), - keybits - masklen); + (gint)(keybits - masklen)); } else if (keybits == 128) { msg_err_radix ("cannot insert %p, key: [%s]/%d, duplicate value", (gpointer)value, inet_ntop (AF_INET6, key, ip_str, sizeof (ip_str) - 1), - keybits - masklen); + (gint)(keybits - masklen)); } else { msg_err_radix ("cannot insert %p with mask %z, key: %*xs, duplicate value", diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c index 4ced0debc..c5a574f6f 100644 --- a/src/libutil/regexp.c +++ b/src/libutil/regexp.c @@ -489,7 +489,7 @@ fin: #endif if (res->raw_re == NULL) { msg_warn ("raw regexp parsing error: '%s': '%s' at position %d", - err_str, (gint)err_off); + err_str, real_pattern, (gint)err_off); } } diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c index e2a530e2f..9686d221a 100644 --- a/src/libutil/sqlite_utils.c +++ b/src/libutil/sqlite_utils.c @@ -423,12 +423,12 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const GString *new_ver_sql; if (sqlite3_prepare (sqlite, db_version, -1, &stmt, NULL) != SQLITE_OK) { - msg_warn_pool_check ("Cannot get user version pragma", + msg_warn_pool_check ("Cannot get user version pragma: %s", sqlite3_errmsg (sqlite)); } else { if (sqlite3_step (stmt) != SQLITE_ROW) { - msg_warn_pool_check ("Cannot get user version pragma, step failed", + msg_warn_pool_check ("Cannot get user version pragma, step failed: %s", sqlite3_errmsg (sqlite)); sqlite3_finalize (stmt); } diff --git a/src/log_helper.c b/src/log_helper.c index 467f98f31..50db8e805 100644 --- a/src/log_helper.c +++ b/src/log_helper.c @@ -94,8 +94,8 @@ rspamd_log_helper_read (gint fd, short what, gpointer ud) (r - sizeof (*sm)) / sizeof (struct rspamd_protocol_log_symbol_result)) { msg_warn ("cannot read data from log pipe: bad length: %d elements " "announced but %d available", n + nextra, - (r - sizeof (*sm)) / - sizeof (struct rspamd_protocol_log_symbol_result)); + (gint)((r - sizeof (*sm)) / + sizeof (struct rspamd_protocol_log_symbol_result))); } else { sm = g_malloc (r); diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c index 3eb44c386..71214b2bc 100644 --- a/src/plugins/dkim_check.c +++ b/src/plugins/dkim_check.c @@ -912,7 +912,7 @@ dkim_sign_callback (struct rspamd_task *task, void *unused) if (ctx == NULL) { msg_err_task ("cannot create sign context: %e", - key, err); + err); g_error_free (err); return; diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index 9286bda89..3b0121f15 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -455,7 +455,8 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, rule->alg = RSPAMD_SHINGLES_FAST; } else { - msg_warn_config ("unknown algorithm: %s, use siphash by default"); + msg_warn_config ("unknown algorithm: %s, use siphash by default", + rule->algorithm_str); } } } diff --git a/src/rspamadm/fuzzy_convert.c b/src/rspamadm/fuzzy_convert.c index 6e31d9aad..84e7b4e5f 100644 --- a/src/rspamadm/fuzzy_convert.c +++ b/src/rspamadm/fuzzy_convert.c @@ -23,7 +23,7 @@ static gchar *source_db = NULL; static gchar *redis_host = NULL; static gchar *redis_db = NULL; static gchar *redis_password = NULL; -static int64_t fuzzy_expiry = NULL; +static int64_t fuzzy_expiry = 0; static void rspamadm_fuzzyconvert (gint argc, gchar **argv); static const char *rspamadm_fuzzyconvert_help (gboolean full_help); diff --git a/src/rspamadm/signtool.c b/src/rspamadm/signtool.c index 75f3790db..ba9fda5a9 100644 --- a/src/rspamadm/signtool.c +++ b/src/rspamadm/signtool.c @@ -536,8 +536,10 @@ rspamadm_signtool (gint argc, gchar **argv) RSPAMD_KEYPAIR_SIGN, mode); if (pk == NULL) { - rspamd_fprintf (stderr, "bad size %s: %ud, %ud expected\n", flen, - rspamd_cryptobox_pk_sig_bytes (mode)); + rspamd_fprintf (stderr, "bad size %s: %ud, %ud expected\n", + pubkey_file, + (guint)flen, + rspamd_cryptobox_pk_sig_bytes (mode)); exit (errno); } -- 2.39.5