Mercurial > dovecot > core-2.2
changeset 9511:a81dfcf5a78d HEAD
Inlined IMAP_ARG_*() macros' error handling functions.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 23 Jun 2009 14:44:24 -0400 |
parents | 5ef9cca6fa27 |
children | e4ba9799a1ac |
files | src/lib-imap/imap-parser.c src/lib-imap/imap-parser.h |
diffstat | 2 files changed, 30 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-imap/imap-parser.c Tue Jun 23 14:30:09 2009 -0400 +++ b/src/lib-imap/imap-parser.c Tue Jun 23 14:44:24 2009 -0400 @@ -726,27 +726,3 @@ return NULL; } } - -char *imap_arg_str_error(const struct imap_arg *arg) -{ - i_panic("Tried to access imap_arg type %d as string", arg->type); -#ifndef ATTRS_DEFINED - return NULL; -#endif -} - -uoff_t imap_arg_literal_size_error(const struct imap_arg *arg) -{ - i_panic("Tried to access imap_arg type %d as literal size", arg->type); -#ifndef ATTRS_DEFINED - return 0; -#endif -} - -ARRAY_TYPE(imap_arg_list) *imap_arg_list_error(const struct imap_arg *arg) -{ - i_panic("Tried to access imap_arg type %d as list", arg->type); -#ifndef ATTRS_DEFINED - return NULL; -#endif -}
--- a/src/lib-imap/imap-parser.h Tue Jun 23 14:30:09 2009 -0400 +++ b/src/lib-imap/imap-parser.h Tue Jun 23 14:44:24 2009 -0400 @@ -68,21 +68,21 @@ #define IMAP_ARG_STR(arg) \ ((arg)->type == IMAP_ARG_NIL ? NULL : \ IMAP_ARG_TYPE_IS_STRING((arg)->type) ? \ - (arg)->_data.str : imap_arg_str_error(arg)) + (arg)->_data.str : imap_arg_str_error()) #define IMAP_ARG_STR_NONULL(arg) \ ((arg)->type == IMAP_ARG_ATOM || (arg)->type == IMAP_ARG_STRING || \ (arg)->type == IMAP_ARG_LITERAL ? \ - (arg)->_data.str : imap_arg_str_error(arg)) + (arg)->_data.str : imap_arg_str_error()) #define IMAP_ARG_LITERAL_SIZE(arg) \ (((arg)->type == IMAP_ARG_LITERAL_SIZE || \ (arg)->type == IMAP_ARG_LITERAL_SIZE_NONSYNC) ? \ - (arg)->_data.literal_size : imap_arg_literal_size_error(arg)) + (arg)->_data.literal_size : imap_arg_literal_size_error()) #define IMAP_ARG_LIST(arg) \ ((arg)->type == IMAP_ARG_LIST ? \ - &(arg)->_data.list : imap_arg_list_error(arg)) + &(arg)->_data.list : imap_arg_list_error()) #define IMAP_ARG_LIST_ARGS(arg) \ array_idx(IMAP_ARG_LIST(arg), 0) #define IMAP_ARG_LIST_COUNT(arg) \ @@ -144,10 +144,31 @@ const char *imap_arg_string(const struct imap_arg *arg); /* Error functions */ -char *imap_arg_str_error(const struct imap_arg *arg) ATTR_NORETURN; -uoff_t imap_arg_literal_size_error(const struct imap_arg *arg) - ATTR_NORETURN; -ARRAY_TYPE(imap_arg_list) *imap_arg_list_error(const struct imap_arg *arg) - ATTR_NORETURN; +static inline char * ATTR_NORETURN +imap_arg_str_error(void) +{ + i_unreached(); +#ifndef ATTRS_DEFINED + return NULL; +#endif +} + +static inline uoff_t ATTR_NORETURN +imap_arg_literal_size_error(void) +{ + i_unreached(); +#ifndef ATTRS_DEFINED + return 0; +#endif +} + +static inline ARRAY_TYPE(imap_arg_list) * ATTR_NORETURN +imap_arg_list_error(void) +{ + i_unreached(); +#ifndef ATTRS_DEFINED + return NULL; +#endif +} #endif