summaryrefslogtreecommitdiffstats
path: root/common/logging.h
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2018-01-25 16:48:07 +0100
committerWerner Koch <wk@gnupg.org>2018-01-25 16:58:29 +0100
commit149369a92b447d06863e79dfe5589321eaf1f237 (patch)
tree7fccbc08e642eca25f8d0327a3d2e3ecc5086e4e /common/logging.h
parentgpg: New maintainer option --debug-set-iobuf-size. (diff)
parentdoc: Note --quick-gen-key as an alias for --quick-generate-key (diff)
downloadgnupg2-149369a92b447d06863e79dfe5589321eaf1f237.tar.xz
gnupg2-149369a92b447d06863e79dfe5589321eaf1f237.zip
Merge branch 'STABLE-BRANCH-2-2' into master
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'common/logging.h')
-rw-r--r--common/logging.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/common/logging.h b/common/logging.h
index 5a82be4a0..a20b8f895 100644
--- a/common/logging.h
+++ b/common/logging.h
@@ -150,4 +150,31 @@ void log_printhex (const void *buffer, size_t length, const char *text);
void log_clock (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
#endif /* Use gnupg internal logging functions. */
+
+/* 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*/