diff options
Diffstat (limited to 'common/logging.h')
-rw-r--r-- | common/logging.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/common/logging.h b/common/logging.h index e1bf56b17..2225100cb 100644 --- a/common/logging.h +++ b/common/logging.h @@ -112,4 +112,30 @@ void log_printhex (const char *text, const void *buffer, size_t length); void log_clock (const char *string); +/* Some handy assertion macros which don't abort. */ + +#define return_if_fail(expr) do { \ + if (!(expr)) { \ + log_debug ("%s:%d: assertion '%s' failed\n", \ + __FILE__, __LINE__, #expr ); \ + return; \ + } } while (0) +#define return_null_if_fail(expr) do { \ + if (!(expr)) { \ + log_debug ("%s:%d: assertion '%s' failed\n", \ + __FILE__, __LINE__, #expr ); \ + return NULL; \ + } } while (0) +#define return_val_if_fail(expr,val) do { \ + if (!(expr)) { \ + log_debug ("%s:%d: assertion '%s' failed\n", \ + __FILE__, __LINE__, #expr ); \ + return (val); \ + } } while (0) +#define never_reached() do { \ + log_debug ("%s:%d: oops - should never get here\n", \ + __FILE__, __LINE__ ); \ + } while (0) + + #endif /*GNUPG_COMMON_LOGGING_H*/ |