[dovecot-cvs] dovecot/src/lib macros.h,1.6,1.7 temp-string.c,1.5,1.6
cras at procontrol.fi
cras at procontrol.fi
Mon Oct 28 11:46:05 EET 2002
Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv13502/src/lib
Modified Files:
macros.h temp-string.c
Log Message:
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.
Index: macros.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/macros.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- macros.h 8 Sep 2002 15:34:27 -0000 1.6
+++ macros.h 28 Oct 2002 09:46:02 -0000 1.7
@@ -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
-
-#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
-
#endif
+
+#define i_unreached() \
+ i_panic("unreached")
#endif
Index: temp-string.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/temp-string.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- temp-string.c 28 Oct 2002 04:50:14 -0000 1.5
+++ temp-string.c 28 Oct 2002 09:46:02 -0000 1.6
@@ -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;
More information about the dovecot-cvs
mailing list