diff options
author | Jonathan Bastien-Filiatrault <joe@x2a.org> | 2010-09-16 23:32:05 -0400 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-09-17 08:14:26 +0200 |
commit | e463a5b53fdc5f3ce46c297f405e3054e11ba73d (patch) | |
tree | bee3bd31a6f6e5772c7bac35a7d31e7c452904d6 /lib/gnutls_errors.h | |
parent | 6dbb25fc258e75faffae57ffba004930313140a0 (diff) | |
download | gnutls-e463a5b53fdc5f3ce46c297f405e3054e11ba73d.tar.gz |
Add gnutls_assert_val idiom.
This warrants being made in an inline function or macro since it is
used throughout the code. This converts 4 line repetitive blocks into
1 line.
Signed-off-by: Jonathan Bastien-Filiatrault <joe@x2a.org>
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Diffstat (limited to 'lib/gnutls_errors.h')
-rw-r--r-- | lib/gnutls_errors.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/gnutls_errors.h b/lib/gnutls_errors.h index 8bc0c6f0d7..7ed3da9f45 100644 --- a/lib/gnutls_errors.h +++ b/lib/gnutls_errors.h @@ -83,4 +83,21 @@ _gnutls_log (int, const char *fmt, ...) #endif /* C99_MACROS */ +/* GCC won't inline this by itself and results in a "fatal warning" + otherwise. Making this a macro has been tried, but it interacts + badly with the do..while in the expansion. Welcome to the dark + side. */ +static inline +#ifdef __GNUC__ + __attribute__ ((always_inline)) +#endif +int +gnutls_assert_val_int (int val, const char* file, int line) +{ + _gnutls_debug_log( "ASSERT: %s:%d\n", file, line); + return val; +} + +#define gnutls_assert_val(x) gnutls_assert_val_int(x, __FILE__, __LINE__) + #endif /* GNUTLS_ERRORS_H */ |