summaryrefslogtreecommitdiff
path: root/epan/proto.h
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2012-04-19 05:44:50 +0000
committerAnders Broman <anders.broman@ericsson.com>2012-04-19 05:44:50 +0000
commit82a60c13d04875c7951435adee4e78c221b5b8e8 (patch)
treee5b6be92fb4216678e82c6ef86a95cec9827b2e0 /epan/proto.h
parent52e6a290c03b174ab157210c1ac68c036f6b72d7 (diff)
downloadwireshark-82a60c13d04875c7951435adee4e78c221b5b8e8.tar.gz
From Evan Huus: Add DISSECTOR_ASSERT_HINT() macro https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7142
svn path=/trunk/; revision=42137
Diffstat (limited to 'epan/proto.h')
-rw-r--r--epan/proto.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/epan/proto.h b/epan/proto.h
index 7b9801106c..4bb1fc36e0 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -135,6 +135,18 @@ typedef struct _protocol protocol_t;
__DISSECTOR_ASSERT (expression, __FILE__, __LINE__))) \
__DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
+/**
+ * Same as DISSECTOR_ASSERT(), but takes an extra 'hint' parameter that
+ * can be used to provide information as to why the assertion might fail.
+ *
+ * @param expression expression to test in the assertion
+ * @param hint message providing extra information
+ */
+#define DISSECTOR_ASSERT_HINT(expression, hint) \
+ ((void) ((expression) ? (void)0 : \
+ __DISSECTOR_ASSERT_HINT (expression, __FILE__, __LINE__, hint))) \
+ __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
+
#if 0
/* win32: using a debug breakpoint (int 3) can be very handy while debugging,
* as the assert handling of GTK/GLib is currently not very helpful */
@@ -162,6 +174,11 @@ typedef struct _protocol protocol_t;
ep_strdup_printf("%s:%u: failed assertion \"%s\"", \
file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression))))
+#define __DISSECTOR_ASSERT_HINT(expression, file, lineno, hint) \
+ (REPORT_DISSECTOR_BUG( \
+ ep_strdup_printf("%s:%u: failed assertion \"%s\" (%s)", \
+ file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression), hint)))
+
/*
* The encoding of a field of a particular type may involve more
* than just whether it's big-endian or little-endian and its size.