From: Jonathan Bastien-Filiatrault Date: Fri, 17 Sep 2010 03:32:05 +0000 (-0400) Subject: Add gnutls_assert_val idiom. X-Git-Tag: gnutls_2_11_3~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e463a5b53fdc5f3ce46c297f405e3054e11ba73d;p=thirdparty%2Fgnutls.git 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 Signed-off-by: Nikos Mavrogiannopoulos --- 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 */