]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Small code changes to make static analyzer happier.
authorTimo Sirainen <tss@iki.fi>
Mon, 5 Apr 2010 06:18:14 +0000 (09:18 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 5 Apr 2010 06:18:14 +0000 (09:18 +0300)
--HG--
branch : HEAD

12 files changed:
src/auth/mech-winbind.c
src/config/config-filter.c
src/doveadm/doveadm.h
src/lib-index/mail-index-sync-ext.c
src/lib-index/mail-transaction-log-view.c
src/lib-mail/message-decoder.c
src/lib-storage/index/index-sort-string.c
src/lib-storage/mail-search.c
src/lib/env-util.c
src/lib/test-istream-concat.c
src/lib/test-istream-seekable.c
src/plugins/expire/expire-plugin.c

index d653562394ba8914c5e5b3cb0ac238948ab0c6c1..26a45b0c35db87e6cc70fe55d90803cc0c187ea6 100644 (file)
@@ -197,7 +197,7 @@ do_auth_continue(struct auth_request *auth_request,
        token = t_strsplit_spaces(answer, " ");
        if (token[0] == NULL ||
            (token[1] == NULL && strcmp(token[0], "BH") != 0) ||
-           (token[2] == NULL && gss_spnego)) {
+           (gss_spnego && (token[1] == NULL || token[2] == NULL))) {
                auth_request_log_error(auth_request, "winbind",
                                       "Invalid input from helper: %s", answer);
                return HR_RESTART;
@@ -241,6 +241,7 @@ do_auth_continue(struct auth_request *auth_request,
                const char *user, *p, *error;
 
                user = gss_spnego ? token[2] : token[1];
+               i_assert(user != NULL);
 
                p = strchr(user, '\\');
                if (p != NULL) {
index 3adbd5f68b8ac80315266d6b7bcb1ae1c9d35578..bf89d397ee6c8ee124cc778d8caa79480be380b0 100644 (file)
@@ -312,7 +312,7 @@ int config_filter_parsers_get(struct config_filter_context *ctx, pool_t pool,
 {
        struct config_filter_parser *const *src;
        struct config_module_parser *dest;
-       const char *error, **error_p;
+       const char *error = NULL, **error_p;
        unsigned int i, count;
 
        src = config_filter_find_all(ctx, module, filter, output_r);
@@ -337,6 +337,7 @@ int config_filter_parsers_get(struct config_filter_context *ctx, pool_t pool,
 
                if (config_module_parser_apply_changes(dest, src[i], pool,
                                                       error_p) < 0) {
+                       i_assert(error != NULL);
                        config_filter_parsers_free(dest);
                        *error_r = error;
                        return -1;
index 44ee8fe55c9973a4099883a1b382379a1335a249..f46f474bbbe32be333219aef5f398a257a8b1ce5 100644 (file)
@@ -24,7 +24,7 @@ extern bool doveadm_verbose, doveadm_debug;
 
 void doveadm_register_cmd(const struct doveadm_cmd *cmd);
 
-void usage(void);
+void usage(void) ATTR_NORETURN;
 void help(const struct doveadm_cmd *cmd);
 
 const char *unixdate2str(time_t timestamp);
index 0c8294c34945784e7dcb12cf9c8214a24c4b33c1..927483b5ab14489c1e7f5c59ea6defe85a2c0913 100644 (file)
@@ -494,10 +494,13 @@ int mail_index_sync_ext_intro(struct mail_index_sync_map_ctx *ctx,
                if (!mail_index_map_lookup_ext(map, name, &ext_map_idx))
                        ext_map_idx = (uint32_t)-1;
        }
-       ext = ext_map_idx == (uint32_t)-1 ? NULL :
-               array_idx(&map->extensions, ext_map_idx);
-       if (ext != NULL)
+       if (ext_map_idx == (uint32_t)-1)
+               ext = NULL;
+       else {
+               ext = array_idx(&map->extensions, ext_map_idx);
                name = ext->name;
+       }
+       i_assert(name != NULL);
 
        if (!ctx->internal_update &&
            strcmp(name, MAIL_INDEX_EXT_KEYWORDS) == 0) {
@@ -525,7 +528,7 @@ int mail_index_sync_ext_intro(struct mail_index_sync_map_ctx *ctx,
                return -1;
        }
 
-       if (ext_map_idx != (uint32_t)-1) {
+       if (ext != NULL) {
                /* exists already */
                if (u->reset_id == ext->reset_id) {
                        /* check if we need to resize anything */
index b57d0e88f48d06c36ab92735d132f707cf33e0b6..89cfcc169bf02d7d899b37d26a5f237d62305e32 100644 (file)
@@ -189,6 +189,7 @@ int mail_transaction_log_view_set(struct mail_transaction_log_view *view,
                view->head = file;
                file = file->next;
        }
+       i_assert(view->tail != NULL);
 
        if (min_file_offset == 0) {
                /* beginning of the file */
index a79a83149d8dac032b5bdf2fced0cfad6bd5e5d5..937a7db9ce66ea7473f69e569fdfb08ce2d85c58 100644 (file)
@@ -252,7 +252,7 @@ static bool message_decode_body(struct message_decoder_context *ctx,
                                struct message_block *output)
 {
        const unsigned char *data = NULL;
-       size_t pos, size = 0;
+       size_t pos = 0, size = 0;
        int ret;
 
        if (ctx->encoding_buf->used != 0) {
index c705f5ff8634ac4b803b213e220ad5f3198673f4..d1adfbe55cab026fe4dc613b955af0f28ed18a4b 100644 (file)
@@ -651,6 +651,8 @@ index_sort_add_ids_range(struct sort_string_context *ctx,
                }
                nodes[i].sort_id_changed = TRUE;
        }
+       i_assert(str != NULL);
+
        return right_str == NULL || strcmp(str, right_str) < 0 ||
                (strcmp(str, right_str) == 0 &&
                 nodes[i-1].sort_id == right_sort_id) ? 0 : -1;
index f823c06fd2fcdca3dd6700c8ffcefe44159a3d65..fff19b629ce8aacabc443dec975b197b8d442607 100644 (file)
@@ -560,8 +560,10 @@ mail_search_args_simplify_sub(struct mailbox *box,
                                SEARCH_OR : SEARCH_SUB;
                        args->not = FALSE;
                        sub = args->value.subargs;
-                       for (; sub != NULL; sub = sub->next)
+                       do {
                                sub->not = !sub->not;
+                               sub = sub->next;
+                       } while (sub != NULL);
                }
 
                if ((args->type == SEARCH_SUB && parent_and) ||
index 163a7227b37918207281635f92dac014c719e5fb..74f6d5a4c7c64da5854a86299b45e317771758de 100644 (file)
@@ -77,6 +77,8 @@ struct env_backup *env_backup_save(void)
        unsigned int i, count;
        pool_t pool;
 
+       i_assert(environ != NULL);
+
        for (count = 0; environ[count] != NULL; count++) ;
 
        pool = pool_alloconly_create("saved environment", 4096);
index 12314472594bf92ec718913f9044df6e1ed5ec16..eb5b62abcd7f386b46f25e3ff89a1b30137963d6 100644 (file)
@@ -65,6 +65,7 @@ static void test_istream_concat_random(void)
                test_istream_set_allow_eof(streams[i], TRUE);
        }
        streams[i] = NULL;
+       i_assert(offset > 0);
 
        input = i_stream_create_concat(streams);
        for (i = 0; i < 100; i++) {
index 955f710290d73b1f8a91cb5925ea707c0a47d3b2..659bb3740ee04c662f0b8f3d41e86827bcb0b866 100644 (file)
@@ -83,6 +83,7 @@ static void test_istream_seekable_random(void)
                test_istream_set_allow_eof(streams[i], TRUE);
        }
        streams[i] = NULL;
+       i_assert(offset > 0);
 
        buffer_size = (rand() % 100) + 1; size = 0;
        input = i_stream_create_seekable(streams, buffer_size, fd_callback, NULL);
index ed63f3196586c1696ec40ec5aae7dd199c39d9de..7bbe762a7d78d9de958cf1cbb3022ad16e7348c6 100644 (file)
@@ -101,7 +101,7 @@ expire_mailbox_transaction_commit(struct mailbox_transaction_context *t,
        struct expire_mailbox *xpr_box = EXPIRE_CONTEXT(t->box);
        struct expire_transaction_context *xt = EXPIRE_CONTEXT(t);
        struct mailbox *box = t->box;
-       time_t new_stamp;
+       time_t new_stamp = 0;
        bool update_dict = FALSE;
        int ret;