Mercurial > dovecot > core-2.2
changeset 546:e1254b838e0b HEAD
Added --enable-asserts (default) and fixed some warnings when building
without. Added i_unreached() to indicate supposedly unreachable code block
and changed a existing i_assert(0) calls to it. Removed return_if_fail() and
return_val_if_fail() macros, they're not useful.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 28 Oct 2002 11:46:02 +0200 |
parents | c97f631bd26d |
children | 39a24074abf4 |
files | acconfig.h configure.in src/auth/auth.c src/auth/userinfo-passwd-file.c src/imap/cmd-append.c src/imap/commands-util.c src/lib-imap/imap-message-cache.c src/lib-imap/imap-parser.c src/lib-index/mail-index-update.c src/lib-storage/index/index-search.c src/lib-storage/index/index-storage.c src/lib-storage/index/index-update-flags.c src/lib/macros.h src/lib/temp-string.c |
diffstat | 14 files changed, 33 insertions(+), 65 deletions(-) [+] |
line wrap: on
line diff
--- a/acconfig.h Mon Oct 28 11:40:15 2002 +0200 +++ b/acconfig.h Mon Oct 28 11:46:02 2002 +0200 @@ -1,6 +1,9 @@ /* Build with extra debugging checks */ #undef DEBUG +/* Disable asserts */ +#undef DISABLE_ASSERTS + /* Build with SSL/TLS support */ #undef HAVE_SSL
--- a/configure.in Mon Oct 28 11:40:15 2002 +0200 +++ b/configure.in Mon Oct 28 11:46:02 2002 +0200 @@ -34,6 +34,12 @@ AC_DEFINE(DEBUG) fi) +AC_ARG_ENABLE(asserts, +[ --enable-asserts Enable asserts (default)], + if test x$enableval = xno; then + AC_DEFINE(DISABLE_ASSERTS) + fi) + AC_ARG_WITH(file-offset-size, [ --with-file-offset-size=BITS Set size of file offsets. Usually 32 or 64. (default: 64 if available)],
--- a/src/auth/auth.c Mon Oct 28 11:40:15 2002 +0200 +++ b/src/auth/auth.c Mon Oct 28 11:46:02 2002 +0200 @@ -75,7 +75,7 @@ } } - i_assert(0); + i_unreached(); } void auth_continue_request(AuthContinuedRequestData *request,
--- a/src/auth/userinfo-passwd-file.c Mon Oct 28 11:40:15 2002 +0200 +++ b/src/auth/userinfo-passwd-file.c Mon Oct 28 11:46:02 2002 +0200 @@ -141,7 +141,7 @@ return FALSE; break; default: - i_assert(0); + i_unreached(); } /* found */
--- a/src/imap/cmd-append.c Mon Oct 28 11:40:15 2002 +0200 +++ b/src/imap/cmd-append.c Mon Oct 28 11:46:02 2002 +0200 @@ -56,7 +56,7 @@ *internal_date = args[2].data.str; break; default: - i_assert(0); + i_unreached(); } /* check that mailbox and message arguments are ok */
--- a/src/imap/commands-util.c Mon Oct 28 11:40:15 2002 +0200 +++ b/src/imap/commands-util.c Mon Oct 28 11:46:02 2002 +0200 @@ -57,7 +57,7 @@ client_send_tagline(client, "NO Mailbox exists."); break; default: - i_assert(0); + i_unreached(); } return FALSE;
--- a/src/lib-imap/imap-message-cache.c Mon Oct 28 11:40:15 2002 +0200 +++ b/src/lib-imap/imap-message-cache.c Mon Oct 28 11:46:02 2002 +0200 @@ -440,7 +440,7 @@ cache_fields(cache, field); return msg->cached_envelope; default: - i_assert(0); + i_unreached(); } return NULL;
--- a/src/lib-imap/imap-parser.c Mon Oct 28 11:40:15 2002 +0200 +++ b/src/lib-imap/imap-parser.c Mon Oct 28 11:46:02 2002 +0200 @@ -219,7 +219,7 @@ } break; default: - i_assert(0); + i_unreached(); } parser->cur_type = ARG_PARSE_NONE; @@ -470,7 +470,7 @@ imap_parser_read_literal_data(parser, data, data_size); break; default: - i_assert(0); + i_unreached(); } return parser->cur_type == ARG_PARSE_NONE;
--- a/src/lib-index/mail-index-update.c Mon Oct 28 11:40:15 2002 +0200 +++ b/src/lib-index/mail-index-update.c Mon Oct 28 11:46:02 2002 +0200 @@ -256,7 +256,7 @@ } static void update_header_field(MailIndexUpdate *update, MailDataField field, - const void *value, size_t size) + const void *value, size_t size __attr_unused__) { switch (field) { case DATA_HDR_INTERNAL_DATE: @@ -276,7 +276,7 @@ update->data_hdr.body_size = *((uoff_t *) value); break; default: - i_assert(0); + i_unreached(); } update->updated_fields |= field;
--- a/src/lib-storage/index/index-search.c Mon Oct 28 11:40:15 2002 +0200 +++ b/src/lib-storage/index/index-search.c Mon Oct 28 11:46:02 2002 +0200 @@ -291,7 +291,7 @@ case SEARCH_SENTSINCE: return sent_time >= search_time; default: - i_assert(0); + i_unreached(); } }
--- a/src/lib-storage/index/index-storage.c Mon Oct 28 11:40:15 2002 +0200 +++ b/src/lib-storage/index/index-storage.c Mon Oct 28 11:46:02 2002 +0200 @@ -72,8 +72,7 @@ } } - /* shouldn't get here */ - i_assert(0); + i_unreached(); } static MailDataField get_data_fields(const char *fields)
--- a/src/lib-storage/index/index-update-flags.c Mon Oct 28 11:40:15 2002 +0200 +++ b/src/lib-storage/index/index-update-flags.c Mon Oct 28 11:46:02 2002 +0200 @@ -31,8 +31,7 @@ flags = ctx->flags; break; default: - flags = 0; - i_assert(0); + i_unreached(); } if (!index->update_flags(index, rec, idx_seq, flags, FALSE))
--- a/src/lib/macros.h Mon Oct 28 11:40:15 2002 +0200 +++ b/src/lib/macros.h Mon Oct 28 11:46:02 2002 +0200 @@ -113,10 +113,8 @@ #endif /* Provide macros for error handling. */ -#ifdef DISABLE_CHECKS +#ifdef DISABLE_ASSERTS # define i_assert(expr) -# define return_if_fail(expr) -# define return_val_if_fail(expr,val) #elif defined (__GNUC__) && !defined (__STRICT_ANSI__) #define i_assert(expr) STMT_START{ \ @@ -127,28 +125,6 @@ __PRETTY_FUNCTION__, \ #expr); }STMT_END -#define return_if_fail(expr) STMT_START{ \ - if (!(expr)) \ - { \ - i_warning("file %s: line %d (%s): assertion `%s' failed.", \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__, \ - #expr); \ - return; \ - }; }STMT_END - -#define return_val_if_fail(expr,val) STMT_START{ \ - if (!(expr)) \ - { \ - i_warning("file %s: line %d (%s): assertion `%s' failed.", \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__, \ - #expr); \ - return val; \ - }; }STMT_END - #else /* !__GNUC__ */ #define i_assert(expr) STMT_START{ \ @@ -158,26 +134,9 @@ __LINE__, \ #expr); }STMT_END -#define return_if_fail(expr) STMT_START{ \ - if (!(expr)) \ - { \ - i_warning("file %s: line %d: assertion `%s' failed.", \ - __FILE__, \ - __LINE__, \ - #expr); \ - return; \ - }; }STMT_END +#endif -#define return_val_if_fail(expr, val) STMT_START{ \ - if (!(expr)) \ - { \ - i_warning("file %s: line %d: assertion `%s' failed.", \ - __FILE__, \ - __LINE__, \ - #expr); \ - return val; \ - }; }STMT_END +#define i_unreached() \ + i_panic("unreached") #endif - -#endif
--- a/src/lib/temp-string.c Mon Oct 28 11:40:15 2002 +0200 +++ b/src/lib/temp-string.c Mon Oct 28 11:46:02 2002 +0200 @@ -33,7 +33,9 @@ size_t len; size_t alloc_size; +#ifndef DISABLE_ASSERTS unsigned int data_stack_frame; +#endif } RealTempString; TempString *t_string_new(size_t initial_size) @@ -44,7 +46,9 @@ initial_size = 64; rstr = t_new(RealTempString, 1); +#ifndef DISABLE_ASSERTS rstr->data_stack_frame = data_stack_frame; +#endif rstr->alloc_size = initial_size; rstr->str = t_malloc(rstr->alloc_size); rstr->str[0] = '\0'; @@ -115,9 +119,8 @@ void t_string_erase(TempString *tstr, size_t pos, size_t len) { - RealTempString *rstr = (RealTempString *) tstr; - - i_assert(data_stack_frame == rstr->data_stack_frame); + i_assert(data_stack_frame == + ((RealTempString *) tstr)->data_stack_frame); i_assert(pos < tstr->len && tstr->len - pos >= len); memmove(tstr->str + pos + len, tstr->str + pos, @@ -126,9 +129,8 @@ void t_string_truncate(TempString *tstr, size_t len) { - RealTempString *rstr = (RealTempString *) tstr; - - i_assert(data_stack_frame == rstr->data_stack_frame); + i_assert(data_stack_frame == + ((RealTempString *) tstr)->data_stack_frame); i_assert(len <= tstr->len); tstr->len = len;