From 3d7650fc497c779e7ca0abc78310250d057f0301 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 20 Dec 2011 19:11:49 +0300 Subject: [PATCH] More cleanups and fixes for compiler warnings. --- CMakeLists.txt | 76 ++++++++++++++++++++------------------------- src/cfg_utils.c | 2 +- src/dns.c | 6 ++-- src/filter.c | 6 ++-- src/fuzzy.c | 6 ++-- src/lua/lua_task.c | 2 +- src/plugins/surbl.c | 2 +- 7 files changed, 46 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbbf23cf3..ee4133e92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -555,48 +555,40 @@ IF(LIBUTIL_LIBRARY) DOC "Path to libutil header") ENDIF(LIBUTIL_LIBRARY) - # Process with warn flags - IF(CMAKE_COMPILER_IS_GNUCC) - CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL) - CHECK_C_COMPILER_FLAG(-Wall SUPPORT_W) - CHECK_C_COMPILER_FLAG(-Wpointer-arith SUPPORT_WPOINTER) - CHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM) - CHECK_C_COMPILER_FLAG(-Wno-unused-function SUPPORT_WFUNCTION) - CHECK_C_COMPILER_FLAG(-Wunused-variable SUPPORT_WUNUSED_VAR) - CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN) - CHECK_C_COMPILER_FLAG(-pedantic SUPPORT_PEDANTIC_FLAG) - CHECK_C_COMPILER_FLAG("-std=c99" SUPPORT_STD_FLAG) - - SET(CMAKE_C_WARN_FLAGS "") - - IF(SUPPORT_W) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -W") - ENDIF(SUPPORT_W) - IF(SUPPORT_WALL) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wall") - ENDIF(SUPPORT_WALL) - IF(SUPPORT_WPOINTER) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wpointer-arith") - ENDIF(SUPPORT_WPOINTER) - IF(SUPPORT_WPARAM) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-parameter") - ENDIF(SUPPORT_WPARAM) - IF(SUPPORT_WFUNCTION) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-function") - ENDIF(SUPPORT_WFUNCTION) - IF(SUPPORT_WUNUSED_VAR) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wunused-variable") - ENDIF(SUPPORT_WUNUSED_VAR) - IF(SUPPORT_WPOINTER_SIGN) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign") - ENDIF(SUPPORT_WPOINTER_SIGN) - IF(SUPPORT_PEDANTIC_FLAG) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -pedantic") - ENDIF(SUPPORT_PEDANTIC_FLAG) - IF(SUPPORT_STD_FLAG) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99") - ENDIF(SUPPORT_STD_FLAG) - ENDIF(CMAKE_COMPILER_IS_GNUCC) +# Process with warn flags +SET(CMAKE_C_WARN_FLAGS "") +CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL) +CHECK_C_COMPILER_FLAG(-Wall SUPPORT_W) +CHECK_C_COMPILER_FLAG(-Wpointer-arith SUPPORT_WPOINTER) +CHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM) +CHECK_C_COMPILER_FLAG(-Wno-unused-function SUPPORT_WFUNCTION) +CHECK_C_COMPILER_FLAG(-Wunused-variable SUPPORT_WUNUSED_VAR) +CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN) +CHECK_C_COMPILER_FLAG(-pedantic SUPPORT_PEDANTIC_FLAG) +IF(SUPPORT_W) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -W") +ENDIF(SUPPORT_W) +IF(SUPPORT_WALL) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wall") +ENDIF(SUPPORT_WALL) +IF(SUPPORT_WPOINTER) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wpointer-arith") +ENDIF(SUPPORT_WPOINTER) +IF(SUPPORT_WPARAM) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-parameter") +ENDIF(SUPPORT_WPARAM) +IF(SUPPORT_WFUNCTION) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-function") +ENDIF(SUPPORT_WFUNCTION) +IF(SUPPORT_WUNUSED_VAR) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wunused-variable") +ENDIF(SUPPORT_WUNUSED_VAR) +IF(SUPPORT_WPOINTER_SIGN) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign") +ENDIF(SUPPORT_WPOINTER_SIGN) +IF(SUPPORT_PEDANTIC_FLAG) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -pedantic") +ENDIF(SUPPORT_PEDANTIC_FLAG) # Optimization flags IF(NOT CMAKE_C_OPT_FLAGS) diff --git a/src/cfg_utils.c b/src/cfg_utils.c index 06faffbcd..2117025ba 100644 --- a/src/cfg_utils.c +++ b/src/cfg_utils.c @@ -101,7 +101,7 @@ gint parse_bind_line (struct config_file *cfg, struct worker_conf *cf, gchar *str) { gchar **host; - gint16 *family, *port; + guint16 *family, *port; struct in_addr *addr; if (str == NULL) diff --git a/src/dns.c b/src/dns.c index 1d868eb58..bd048c4ac 100644 --- a/src/dns.c +++ b/src/dns.c @@ -531,7 +531,7 @@ format_dns_name (struct rspamd_dns_request *req, const gchar *name, guint namele gunichar *uclabel; glong uclabel_len; gsize punylabel_len; - gchar tmp_label[DNS_D_MAXLABEL]; + guint8 tmp_label[DNS_D_MAXLABEL]; if (namelen == 0) { namelen = strlen (name); @@ -543,11 +543,11 @@ format_dns_name (struct rspamd_dns_request *req, const gchar *name, guint namele /* Check label for unicode characters */ if (maybe_punycode_label (begin, &name_pos, &dot, &label_len)) { /* Convert to ucs4 */ - uclabel = g_utf8_to_ucs4_fast (begin, label_len, &uclabel_len); + uclabel = g_utf8_to_ucs4_fast ((gchar *)begin, label_len, &uclabel_len); memory_pool_add_destructor (req->pool, g_free, uclabel); punylabel_len = DNS_D_MAXLABEL; - punycode_label_toascii (uclabel, uclabel_len, tmp_label, &punylabel_len); + punycode_label_toascii (uclabel, uclabel_len, (gchar *)tmp_label, &punylabel_len); /* Try to compress name */ if (! try_compress_label (req->pool, pos, req->packet, punylabel_len, tmp_label, &table)) { /* Copy punylabel */ diff --git a/src/filter.c b/src/filter.c index 562f705e5..22693eb8d 100644 --- a/src/filter.c +++ b/src/filter.c @@ -566,7 +566,7 @@ classifiers_callback (gpointer value, void *arg) break; } } - c.begin = text_part->content->data; + c.begin = (gchar *)text_part->content->data; c.len = text_part->content->len; /* Tree would be freed at task pool freeing */ if (!cl->tokenizer->tokenize_func (cl->tokenizer, task->task_pool, &c, &tokens, @@ -800,7 +800,7 @@ learn_task (const gchar *statfile, struct worker_task *task, GError **err) cur = g_list_next (cur); continue; } - c.begin = part->content->data; + c.begin = (gchar *)part->content->data; c.len = part->content->len; is_utf = part->is_utf; ex = part->urls_offset; @@ -899,7 +899,7 @@ learn_task_spam (struct classifier_config *cl, struct worker_task *task, gboolea cur = g_list_next (cur); continue; } - c.begin = part->content->data; + c.begin = (gchar *)part->content->data; c.len = part->content->len; is_utf = part->is_utf; ex = part->urls_offset; diff --git a/src/fuzzy.c b/src/fuzzy.c index 3901375ca..b14c2a9f9 100644 --- a/src/fuzzy.c +++ b/src/fuzzy.c @@ -306,7 +306,7 @@ fuzzy_init_byte_array (GByteArray * in, memory_pool_t * pool) { f_str_t f; - f.begin = in->data; + f.begin = (gchar *)in->data; f.len = in->len; return fuzzy_init (&f, pool); @@ -328,7 +328,7 @@ fuzzy_init_part (struct mime_text_part *part, memory_pool_t *pool, gsize max_dif cur_ex = cur_offset->data; } - begin = part->content->data; + begin = (gchar *)part->content->data; c = begin; new = memory_pool_alloc0 (pool, sizeof (fuzzy_hash_t)); new2 = memory_pool_alloc0 (pool, sizeof (fuzzy_hash_t)); @@ -388,7 +388,7 @@ fuzzy_init_part (struct mime_text_part *part, memory_pool_t *pool, gsize max_dif cur_ex = cur_offset->data; } - begin = part->content->data; + begin = (gchar *)part->content->data; c = begin; end = c + len; if (part->is_utf) { diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 7cca35c3d..c0b299fb7 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -1248,7 +1248,7 @@ lua_textpart_get_content (lua_State * L) return 1; } - lua_pushlstring (L, part->content->data, part->content->len); + lua_pushlstring (L, (const gchar *)part->content->data, part->content->len); return 1; } diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index b1f51b7fc..fe0c1d6de 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -514,7 +514,7 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it /* Check for numeric expressions */ if (is_numeric && dots_num == 3) { /* This is ip address */ - if ((suffix->options & SURBL_OPTION_NOIP) != 0) { + if (suffix != NULL && (suffix->options & SURBL_OPTION_NOIP) != 0) { /* Ignore such requests */ msg_info ("ignore request of ip url for list %s", suffix->symbol); return NULL; -- 2.39.5