From: Timo Sirainen Date: Mon, 5 Apr 2010 06:18:14 +0000 (+0300) Subject: Small code changes to make static analyzer happier. X-Git-Tag: 2.0.beta5~200 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e376e08040b5f21ff79a15ae728d2532a34207f6;p=thirdparty%2Fdovecot%2Fcore.git Small code changes to make static analyzer happier. --HG-- branch : HEAD --- diff --git a/src/auth/mech-winbind.c b/src/auth/mech-winbind.c index d653562394..26a45b0c35 100644 --- a/src/auth/mech-winbind.c +++ b/src/auth/mech-winbind.c @@ -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) { diff --git a/src/config/config-filter.c b/src/config/config-filter.c index 3adbd5f68b..bf89d397ee 100644 --- a/src/config/config-filter.c +++ b/src/config/config-filter.c @@ -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; diff --git a/src/doveadm/doveadm.h b/src/doveadm/doveadm.h index 44ee8fe55c..f46f474bbb 100644 --- a/src/doveadm/doveadm.h +++ b/src/doveadm/doveadm.h @@ -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); diff --git a/src/lib-index/mail-index-sync-ext.c b/src/lib-index/mail-index-sync-ext.c index 0c8294c349..927483b5ab 100644 --- a/src/lib-index/mail-index-sync-ext.c +++ b/src/lib-index/mail-index-sync-ext.c @@ -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 */ diff --git a/src/lib-index/mail-transaction-log-view.c b/src/lib-index/mail-transaction-log-view.c index b57d0e88f4..89cfcc169b 100644 --- a/src/lib-index/mail-transaction-log-view.c +++ b/src/lib-index/mail-transaction-log-view.c @@ -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 */ diff --git a/src/lib-mail/message-decoder.c b/src/lib-mail/message-decoder.c index a79a83149d..937a7db9ce 100644 --- a/src/lib-mail/message-decoder.c +++ b/src/lib-mail/message-decoder.c @@ -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) { diff --git a/src/lib-storage/index/index-sort-string.c b/src/lib-storage/index/index-sort-string.c index c705f5ff86..d1adfbe55c 100644 --- a/src/lib-storage/index/index-sort-string.c +++ b/src/lib-storage/index/index-sort-string.c @@ -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; diff --git a/src/lib-storage/mail-search.c b/src/lib-storage/mail-search.c index f823c06fd2..fff19b629c 100644 --- a/src/lib-storage/mail-search.c +++ b/src/lib-storage/mail-search.c @@ -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) || diff --git a/src/lib/env-util.c b/src/lib/env-util.c index 163a7227b3..74f6d5a4c7 100644 --- a/src/lib/env-util.c +++ b/src/lib/env-util.c @@ -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); diff --git a/src/lib/test-istream-concat.c b/src/lib/test-istream-concat.c index 1231447259..eb5b62abcd 100644 --- a/src/lib/test-istream-concat.c +++ b/src/lib/test-istream-concat.c @@ -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++) { diff --git a/src/lib/test-istream-seekable.c b/src/lib/test-istream-seekable.c index 955f710290..659bb3740e 100644 --- a/src/lib/test-istream-seekable.c +++ b/src/lib/test-istream-seekable.c @@ -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); diff --git a/src/plugins/expire/expire-plugin.c b/src/plugins/expire/expire-plugin.c index ed63f31965..7bbe762a7d 100644 --- a/src/plugins/expire/expire-plugin.c +++ b/src/plugins/expire/expire-plugin.c @@ -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;