]> source.dussan.org Git - rspamd.git/commitdiff
More cleanups and fixes for compiler warnings. 0.4.6
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 20 Dec 2011 16:11:49 +0000 (19:11 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 20 Dec 2011 16:11:49 +0000 (19:11 +0300)
CMakeLists.txt
src/cfg_utils.c
src/dns.c
src/filter.c
src/fuzzy.c
src/lua/lua_task.c
src/plugins/surbl.c

index bbbf23cf304fb5fccd1ee666e4f332c4345fdfed..ee4133e925ed84ae56ed5c59e80c4c9ddc8b593e 100644 (file)
@@ -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)
index 06faffbcd2e8554f1b7f1e927fd3ff5b875e984e..2117025ba6cfe3efdf84892f653d45d0144579e9 100644 (file)
@@ -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)
index 1d868eb5806d24fa8a2c9e7700341976e500f684..bd048c4ac01c54c85d6dc0a8e3ef07ab614a5edc 100644 (file)
--- 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 */
index 562f705e5dfde961a788307e97b74df44f038689..22693eb8d2653fe4b2b802ba1dd7b3e358f4b5de 100644 (file)
@@ -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;
index 3901375caeff422d1a41247b6f3114c959ac6687..b14c2a9f9296ded8fcf331ab00cff7cd5a7cb48a 100644 (file)
@@ -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) {
index 7cca35c3d79d8378b97e4025bf4b42b2681b9b10..c0b299fb750c7fb299d1e864394910838270e679 100644 (file)
@@ -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;
 }
index b1f51b7fc991b7ca2b99641cf6daa351a401713b..fe0c1d6de3e1a9b2b649cbb107f7b6c9aa49c311 100644 (file)
@@ -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;