Mercurial > dovecot > core-2.2
changeset 11076:fa08ed2b7560 HEAD
Small code changes to make static analyzer happier.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 05 Apr 2010 10:44:06 +0300 |
parents | 3b8542d58181 |
children | 8627be1f6de9 |
files | src/config/config-request.c src/lib-index/mail-cache-compress.c src/lib-index/mailbox-list-index-sync.c src/lib-index/test-mail-transaction-log-view.c src/lib-mail/test-message-id.c src/lib-storage/mail-storage-service.c src/lib/test-istream-crlf.c |
diffstat | 7 files changed, 25 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/config/config-request.c Mon Apr 05 10:36:31 2010 +0300 +++ b/src/config/config-request.c Mon Apr 05 10:44:06 2010 +0300 @@ -100,13 +100,19 @@ } case SET_ENUM: { const char *const *val = value; - const char *const *_dval = default_value; - const char *dval = _dval == NULL ? NULL : *_dval; unsigned int len = strlen(*val); - if (dump_default || strncmp(*val, dval, len) != 0 || - ((*val)[len] != ':' && (*val)[len] != '\0')) + if (dump_default) str_append(str, *val); + else { + const char *const *_dval = default_value; + const char *dval = _dval == NULL ? NULL : *_dval; + + i_assert(dval != NULL); + if (strncmp(*val, dval, len) != 0 || + ((*val)[len] != ':' && (*val)[len] != '\0')) + str_append(str, *val); + } break; } default:
--- a/src/lib-index/mail-cache-compress.c Mon Apr 05 10:36:31 2010 +0300 +++ b/src/lib-index/mail-cache-compress.c Mon Apr 05 10:44:06 2010 +0300 @@ -131,6 +131,7 @@ idx = cache->field_file_map[i]; if (idx != (uint32_t)-1) { i_assert(idx < used_fields_count && + cache->file_field_map != NULL && cache->file_field_map[idx] == 0); cache->file_field_map[idx] = i; j++; @@ -182,7 +183,7 @@ ctx.buffer = buffer_create_dynamic(default_pool, 4096); ctx.field_seen = buffer_create_dynamic(default_pool, 64); ctx.field_seen_value = 0; - ctx.field_file_map = t_new(uint32_t, cache->fields_count); + ctx.field_file_map = t_new(uint32_t, cache->fields_count + 1); t_array_init(&ctx.bitmask_pos, 32); /* @UNSAFE: drop unused fields and create a field mapping for
--- a/src/lib-index/mailbox-list-index-sync.c Mon Apr 05 10:36:31 2010 +0300 +++ b/src/lib-index/mailbox-list-index-sync.c Mon Apr 05 10:44:06 2010 +0300 @@ -615,6 +615,7 @@ name_pos += size; } else { /* existing record. need to find its name_offset */ + i_assert(dir != NULL); for (orig = 0; orig < dir->count; orig++) { if (recs[orig].uid == sync_recs[src].uid) break;
--- a/src/lib-index/test-mail-transaction-log-view.c Mon Apr 05 10:36:31 2010 +0300 +++ b/src/lib-index/test-mail-transaction-log-view.c Mon Apr 05 10:44:06 2010 +0300 @@ -139,7 +139,8 @@ add_append_record(log->head, &append_rec); view = mail_transaction_log_view_open(log); - test_assert(view != NULL && log->views == view && + i_assert(view != NULL); + test_assert(log->views == view && !view_is_file_refed(1) && !view_is_file_refed(2) && view_is_file_refed(3)); test_end();
--- a/src/lib-mail/test-message-id.c Mon Apr 05 10:36:31 2010 +0300 +++ b/src/lib-mail/test-message-id.c Mon Apr 05 10:44:06 2010 +0300 @@ -22,9 +22,12 @@ test_begin("message id parser"); for (i = 0, j = 0; i < N_ELEMENTS(input); i++) { msgid = input[i]; - while ((next_msgid = message_id_get_next(&msgid)) != NULL) + while ((next_msgid = message_id_get_next(&msgid)) != NULL) { + if (output[j] == NULL) + break; test_assert(strcmp(output[j++], next_msgid) == 0); - test_assert(output[j++] == NULL); + } + test_assert(output[j++] == NULL && next_msgid == NULL); } test_assert(j == N_ELEMENTS(output)); test_end();
--- a/src/lib-storage/mail-storage-service.c Mon Apr 05 10:36:31 2010 +0300 +++ b/src/lib-storage/mail-storage-service.c Mon Apr 05 10:44:06 2010 +0300 @@ -569,7 +569,10 @@ ctx->set_roots = p_new(pool, const struct setting_parser_info *, count + 2); ctx->set_roots[0] = &mail_user_setting_parser_info; - memcpy(ctx->set_roots + 1, set_roots, sizeof(*ctx->set_roots) * count); + if (set_roots != NULL) { + memcpy(ctx->set_roots + 1, set_roots, + sizeof(*ctx->set_roots) * count); + } /* do all the global initialization. delay initializing plugins until we drop privileges the first time. */
--- a/src/lib/test-istream-crlf.c Mon Apr 05 10:36:31 2010 +0300 +++ b/src/lib/test-istream-crlf.c Mon Apr 05 10:44:06 2010 +0300 @@ -9,7 +9,7 @@ { string_t *output; const unsigned char *data; - size_t size; + size_t size = 0; ssize_t ret1, ret2; unsigned int i, j, pos, input_len = strlen(input); struct istream *istream, *crlf_istream;