]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Add gnutls_assert_val idiom.
authorJonathan Bastien-Filiatrault <joe@x2a.org>
Fri, 17 Sep 2010 03:32:05 +0000 (23:32 -0400)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 17 Sep 2010 06:14:26 +0000 (08:14 +0200)
 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>
lib/gnutls_errors.h

index 8bc0c6f0d781b95510a6305da7b47c403e56d5a8..7ed3da9f45aa0687f455ed55723b3f3feb86be77 100644 (file)
@@ -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 */