From 3b025570d4fd2bdd92c1a588ae494c4e2aa4db43 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 24 May 2013 13:11:52 +0100 Subject: [PATCH] Fix several potential problems found by static analysis. --- src/cfg_xml.c | 10 ++++++++-- src/dkim.c | 4 ++-- src/expressions.h | 2 +- src/lua/lua_buffer.c | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cfg_xml.c b/src/cfg_xml.c index 322772825..054377059 100644 --- a/src/cfg_xml.c +++ b/src/cfg_xml.c @@ -897,8 +897,10 @@ worker_foreach_callback (gpointer k, gpointer v, gpointer ud) GList *cur; GHashTable *worker_config; - if (!worker_options || (worker_config = g_hash_table_lookup (worker_options, &cd->wrk->type)) == NULL || - (cparam = g_hash_table_lookup (worker_config, k)) == NULL) { + if (!worker_options || (worker_config = g_hash_table_lookup (worker_options, &cd->wrk->type)) == NULL) { + return; + } + if ((cparam = g_hash_table_lookup (worker_config, k)) == NULL) { /* Try to use universal handler if there is no specific handler */ if ((cparam = g_hash_table_lookup (worker_config, "*")) != NULL) { if (cd->wrk->ctx != NULL) { @@ -1114,6 +1116,10 @@ handle_metric_symbol (struct config_file *cfg, struct rspamd_xml_userdata *ctx, group = "ungrouped"; } } + else { + group = "ungrouped"; + sym_def->description = NULL; + } g_hash_table_insert (metric->symbols, sym_def->name, value); diff --git a/src/dkim.c b/src/dkim.c index feb11893d..157b13aee 100644 --- a/src/dkim.c +++ b/src/dkim.c @@ -579,14 +579,14 @@ rspamd_create_dkim_context (const gchar *sig, memory_pool_t *pool, guint time_ji } if (new->sig_alg == DKIM_SIGN_RSASHA1) { /* Check bh length */ - if (new->bhlen != g_checksum_type_get_length (G_CHECKSUM_SHA1)) { + if (new->bhlen != (guint)g_checksum_type_get_length (G_CHECKSUM_SHA1)) { g_set_error (err, DKIM_ERROR, DKIM_SIGERROR_BADSIG, "signature has incorrect length: %ud", new->bhlen); return NULL; } } else if (new->sig_alg == DKIM_SIGN_RSASHA256) { - if (new->bhlen != g_checksum_type_get_length (G_CHECKSUM_SHA256)) { + if (new->bhlen != (guint)g_checksum_type_get_length (G_CHECKSUM_SHA256)) { g_set_error (err, DKIM_ERROR, DKIM_SIGERROR_BADSIG, "signature has incorrect length: %ud", new->bhlen); return NULL; } diff --git a/src/expressions.h b/src/expressions.h index 6f42fa3e4..1ec3106c0 100644 --- a/src/expressions.h +++ b/src/expressions.h @@ -97,7 +97,7 @@ void re_cache_add (const gchar *line, void *pointer, memory_pool_t *pool); * @param line symbolic representation * @return pointer to regexp data or NULL if regexp is not found */ -void * re_cache_check (const const gchar *line, memory_pool_t *pool); +void * re_cache_check (const gchar *line, memory_pool_t *pool); /** * Remove regexp from regexp cache diff --git a/src/lua/lua_buffer.c b/src/lua/lua_buffer.c index b7a460b52..ee2b5d158 100644 --- a/src/lua/lua_buffer.c +++ b/src/lua/lua_buffer.c @@ -106,7 +106,7 @@ static gboolean lua_io_write_cb (void *arg) { struct lua_dispatcher_cbdata *cbdata = arg; - gboolean res; + gboolean res = FALSE; rspamd_io_dispatcher_t **pdispatcher; if (cbdata->cbref_write) { -- 2.39.5