]> source.dussan.org Git - rspamd.git/commitdiff
Make compiler happy in several cases, remove warnings.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 20 Dec 2011 14:11:39 +0000 (17:11 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 20 Dec 2011 14:11:39 +0000 (17:11 +0300)
lib/client/librspamdclient.c
src/cfg_xml.c
src/diff.c
src/expressions.c
src/kvstorage_config.c
src/kvstorage_file.c
src/kvstorage_server.c
src/message.c
src/protocol.c
src/url.c
src/util.c

index 55a9b13dce0cf90407e2157479ba993b47713041..dad2a3388d0f87b86c8d012e5435ada7eca522b9 100644 (file)
@@ -323,7 +323,7 @@ static gboolean
 parse_rspamd_first_line (struct rspamd_connection *conn, guint len, GError **err)
 {
        gchar                           *b = conn->in_buf->str + sizeof("RSPAMD/") - 1, *p, *c;
-       guint                            remain = len - sizeof("RSPAMD/") + 1, state = 0, next_state;
+       guint                            remain = len - sizeof("RSPAMD/") + 1, state = 0, next_state = 0;
        gdouble                          dver;
 
        p = b;
@@ -401,8 +401,8 @@ static gboolean
 parse_rspamd_metric_line (struct rspamd_connection *conn, guint len, GError **err)
 {
        gchar                           *b = conn->in_buf->str + sizeof("Metric:") - 1, *p, *c, *err_str;
-       guint                            remain = len - sizeof("Metric:") + 1, state = 0, next_state;
-       struct rspamd_metric            *new;
+       guint                            remain = len - sizeof("Metric:") + 1, state = 0, next_state = 0;
+       struct rspamd_metric            *new = NULL;
 
        p = b;
 
@@ -543,8 +543,8 @@ static gboolean
 parse_rspamd_symbol_line (struct rspamd_connection *conn, guint len, GError **err)
 {
        gchar                           *b = conn->in_buf->str + sizeof("Symbol:") - 1, *p, *c, *err_str, *sym;
-       guint                            remain = len - sizeof("Symbol:") + 1, state = 0, next_state, l;
-       struct rspamd_symbol            *new;
+       guint                            remain = len - sizeof("Symbol:") + 1, state = 0, next_state = 0, l;
+       struct rspamd_symbol            *new = NULL;
 
        p = b;
        while (g_ascii_isspace (*p)) {
@@ -684,7 +684,7 @@ static gboolean
 parse_rspamd_action_line (struct rspamd_connection *conn, guint len, GError **err)
 {
        gchar                           *b = conn->in_buf->str + sizeof("Action:") - 1, *p, *c, *sym;
-       guint                            remain = len - sizeof("Action:") + 1, state = 0, next_state;
+       guint                            remain = len - sizeof("Action:") + 1, state = 0, next_state = 0;
 
        p = b;
        c = b;
@@ -752,7 +752,7 @@ static gboolean
 parse_rspamd_header_line (struct rspamd_connection *conn, guint len, GError **err)
 {
        gchar                           *b = conn->in_buf->str, *p, *c, *hname = NULL, *hvalue = NULL;
-       guint                            remain = len, state = 0, next_state;
+       guint                            remain = len, state = 0, next_state = 0;
 
        p = b;
        c = b;
index 4b3a7970d37259f905def465b1b02212aa8ccfda..87929f5107c4925e8a6bc2e00925bd5fcee5d0f3 100644 (file)
@@ -2097,6 +2097,11 @@ check_module_option (const gchar *mname, const gchar *optname, const gchar *data
        GHashTable                       *module;
        gchar                            *err_str;
        struct option_callback_data       cd;
+       union {
+               gint i;
+               gdouble d;
+               guint ui;
+       }                                 t;
 
        if (module_options == NULL) {
                msg_warn ("no module options registered while checking option %s for module %s", mname, optname);
@@ -2128,39 +2133,44 @@ check_module_option (const gchar *mname, const gchar *optname, const gchar *data
                /* Allways OK */
                return TRUE;
        case MODULE_OPT_TYPE_INT:
-               (void)strtol (data, &err_str, 10);
+               t.i = strtol (data, &err_str, 10);
                if (*err_str != '\0') {
                        msg_warn ("non-numeric data for option: '%s' for module: '%s' at position: '%s'", optname, mname, err_str);
                        return FALSE;
                }
+               (void)t.i;
                break;
        case MODULE_OPT_TYPE_UINT:
-               (void)strtoul (data, &err_str, 10);
+               t.ui = strtoul (data, &err_str, 10);
                if (*err_str != '\0') {
                        msg_warn ("non-numeric data for option: '%s' for module: '%s' at position: '%s'", optname, mname, err_str);
                        return FALSE;
                }
+               (void)t.ui;
                break;
        case MODULE_OPT_TYPE_DOUBLE:
-               (void)strtod (data, &err_str);
+               t.d = strtod (data, &err_str);
                if (*err_str != '\0') {
                        msg_warn ("non-numeric data for option: '%s' for module: '%s' at position: '%s'", optname, mname, err_str);
                        return FALSE;
                }
+               (void)t.d;
                break;
        case MODULE_OPT_TYPE_TIME:
-               (void)cfg_parse_time (data, TIME_SECONDS);
+               t.ui = cfg_parse_time (data, TIME_SECONDS);
                if (errno != 0) {
                        msg_warn ("non-numeric data for option: '%s' for module: '%s': %s", optname, mname, strerror (errno));
                        return FALSE;
                }
+               (void)t.ui;
                break;
        case MODULE_OPT_TYPE_SIZE:
-               (void)parse_limit (data, -1);
+               t.ui = parse_limit (data, -1);
                if (errno != 0) {
                        msg_warn ("non-numeric data for option: '%s' for module: '%s': %s", optname, mname, strerror (errno));
                        return FALSE;
                }
+               (void)t.ui;
                break;
        case MODULE_OPT_TYPE_MAP:
                if (!check_map_proto (data, NULL, NULL)) {
index 56f4498ca9659b536381f455cc70a65d6cd7b92d..f7606cb047a722f3511c7fce2d414a9f78bfc5c6 100644 (file)
@@ -225,7 +225,12 @@ static gint
 _ses(const void *a, gint aoff, gint n, const void *b, gint boff,
                gint m, struct _ctx *ctx)
 {
-       struct middle_snake ms;
+       struct middle_snake ms = {
+               .x = 0,
+               .y = 0,
+               .u = 0,
+               .v = 0
+       };
        gint d;
 
        if (n == 0) {
index 3012d2d5d4f6c23a8291d6231717fc6155b929dd..99277dfd25c6e7a94627c5a2a8270edeef474a29 100644 (file)
@@ -1144,7 +1144,7 @@ rspamd_content_type_compare_param (struct worker_task * task, GList * args, void
        GMimeContentType               *ct;
        gint                            r;
        gboolean                        recursive = FALSE, result = FALSE;
-       GList                          *cur;
+       GList                          *cur = NULL;
        struct mime_part               *cur_part;
 
        if (args == NULL) {
@@ -1253,7 +1253,7 @@ rspamd_content_type_has_param (struct worker_task * task, GList * args, void *un
        GMimeObject                    *part;
        GMimeContentType               *ct;
        gboolean                        recursive = FALSE, result = FALSE;
-       GList                          *cur;
+       GList                          *cur = NULL;
        struct mime_part               *cur_part;
 
        if (args == NULL) {
@@ -1326,7 +1326,7 @@ rspamd_content_type_is_subtype (struct worker_task *task, GList * args, void *un
        GMimeContentType               *ct;
        gint                            r;
        gboolean                        recursive = FALSE, result = FALSE;
-       GList                          *cur;
+       GList                          *cur = NULL;
        struct mime_part               *cur_part;
 
        if (args == NULL) {
@@ -1423,7 +1423,7 @@ rspamd_content_type_is_type (struct worker_task * task, GList * args, void *unus
        GMimeContentType               *ct;
        gint                            r;
        gboolean                        recursive = FALSE, result = FALSE;
-       GList                          *cur;
+       GList                          *cur = NULL;
        struct mime_part               *cur_part;
 
        if (args == NULL) {
index 0902c73035b180954c14aaa798e729f46ef06fa1..fd259c834786f208bbebc48651260a0d305f672f 100644 (file)
@@ -87,8 +87,8 @@ kvstorage_init_callback (const gpointer key, const gpointer value, gpointer unus
 {
        struct kvstorage_config                         *kconf = value;
        struct rspamd_kv_cache                          *cache;
-       struct rspamd_kv_backend                        *backend;
-       struct rspamd_kv_expire                         *expire;
+       struct rspamd_kv_backend                        *backend = NULL;
+       struct rspamd_kv_expire                         *expire = NULL;
 
        switch (kconf->cache.type) {
        case KVSTORAGE_TYPE_CACHE_HASH:
index 73e5a8a881ef9a3402ed57d1d2eb9ffa920280ca..de06f778b0c0cc195d6a4a7c90e5577f948095ec 100644 (file)
@@ -339,11 +339,17 @@ rspamd_recursive_mkdir (guint levels)
                                return FALSE;
                        }
                        else if (levels > 1) {
-                               chdir (nbuf);
+                               if (chdir (nbuf) == -1) {
+                                       msg_err ("chdir to %s failed: %s", nbuf, strerror (errno));
+                                       return FALSE;
+                               }
                                if (! rspamd_recursive_mkdir (levels - 1)) {
                                        return FALSE;
                                }
-                               chdir ("../");
+                               if (chdir ("../") == -1) {
+                                       msg_err ("chdir to ../ failed: %s", strerror (errno));
+                                       return FALSE;
+                               }
                        }
                }
        }
@@ -378,11 +384,15 @@ rspamd_file_init (struct rspamd_kv_backend *backend)
 
        db->initialized = TRUE;
 
-       chdir (pathbuf);
+       if (chdir (pathbuf) == -1) {
+               msg_err ("chdir to %s failed: %s", pathbuf, strerror (errno));
+       }
        return;
 err:
        if (pathbuf[0] != '\0') {
-               chdir (pathbuf);
+               if (chdir (pathbuf) == -1) {
+                       msg_err ("chdir to %s failed: %s", pathbuf, strerror (errno));
+               }
        }
 }
 
index 7cf53f1a09c5a3ed9e1721d25dcd4929fc9d8726..c55c7c37e30c3238fa41e7069f79967f52038c71 100644 (file)
@@ -222,7 +222,7 @@ static gboolean
 parse_kvstorage_line (struct kvstorage_session *session, f_str_t *in)
 {
        gchar                                                           *p, *c, *end;
-       gint                                                             state = 0, next_state;
+       gint                                                             state = 0, next_state = 0;
        gboolean                                                         is_redis;
 
        p = in->begin;
@@ -648,6 +648,7 @@ kvstorage_read_arglen (f_str_t *in, guint *len)
        gchar                                                           *p = in->begin, *end = in->begin + in->len, *c;
        gint                                                             state = 0;
 
+       c = p;
        while (p < end) {
                switch (state) {
                case 0:
@@ -716,7 +717,7 @@ kvstorage_read_socket (f_str_t * in, void *arg)
        struct kvstorage_session                        *session = (struct kvstorage_session *) arg;
        struct kvstorage_worker_thread          *thr;
        gint                                                             r;
-       guint                                                            arglen;
+       guint                                                            arglen = 0;
        gchar                                                            outbuf[BUFSIZ];
        gboolean                                                         is_redis;
 
index 19d56f7dffd58b0d3a387d5541dfa319f5a487c6..bf955ae942548d59a32270ea201c707f05d52e7e 100644 (file)
@@ -470,9 +470,9 @@ parse_recv_header (memory_pool_t * pool, gchar *line, struct received_header *r)
 static void
 process_raw_headers (struct worker_task *task)
 {
-       struct raw_header              *new, *lp;
+       struct raw_header              *new = NULL, *lp;
        gchar                          *p, *c, *tmp, *tp;
-       gint                            state = 0, l, next_state, err_state, t_state;
+       gint                            state = 0, l, next_state = 100, err_state = 100, t_state;
        gboolean                        valid_folding = FALSE;
 
        p = task->raw_headers_str;
index 70ba1bd8318faffc3a382604314141f25c3e5c6c..51290cdf1fc734da14fcde001690b226b871e2ad 100644 (file)
@@ -292,10 +292,11 @@ static gboolean
 parse_http_command (struct worker_task *task, f_str_t * line)
 {
        guint8                         *p, *end, *c;
-       gint                            state = 0, next_state;
+       gint                            state = 0, next_state = 0;
        gchar                          *cmd;
 
        p = line->begin;
+       c = p;
        end = p + line->len;
        task->proto = RSPAMC_PROTO;
 
index 8e0449093987684380163ba74cc86a44aee172f2..ade68ea1c630949d34f4359c17becdfe6c021c47 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -918,9 +918,10 @@ url_file_end (const gchar *begin, const gchar *end, const gchar *pos, url_match_
 {
        const gchar                    *p;
        gchar                           stop;
-       guint                            i;
+       guint                           i;
 
        p = pos + strlen (match->pattern);
+       stop = *p;
        if (*p == '/') {
                p ++;
        }
index c5ec0145eec7a939187c8fe553f3d2141ed22681..23203255b4a9015eab26b8b3555506660a21b199 100644 (file)
@@ -408,7 +408,9 @@ write_pid (struct rspamd_main *main)
 
        if (main->is_privilleged) {
                /* Force root user as owner of pid file */
-               fchown (main->pfh->pf_fd, 0, 0);
+               if (fchown (main->pfh->pf_fd, 0, 0) == -1) {
+                       msg_err ("cannot chown of pidfile %s to 0:0 user", main->cfg->pid_file);
+               }
        }
 
        rspamd_pidfile_write (main->pfh);