From 2617e403563e10643a84e0af550642a2e6b7c751 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Mon, 17 Jan 2005 00:18:39 +0000 Subject: [PATCH] Add a REPORT_DISSECTOR_BUG() macro to let caller-specified messages be used in DissectorError exceptions. svn path=/trunk/; revision=13079 --- epan/proto.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/epan/proto.h b/epan/proto.h index 9253450d07..930b97bbaa 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -78,9 +78,24 @@ typedef struct _protocol protocol_t; } \ } +/** Macro used for reporting errors in dissectors; it throws a + * DissectorError exception, with the string passed as an argument + * as the message for the exception, so that it can show up in + * the Info column and the protocol tree. + * + * That string should be allocated with g_malloc(); using + * "g_strdup_printf()" would work. + * + * @param message string to use as the message + */ +#define REPORT_DISSECTOR_BUG(message) \ + (THROW_MESSAGE(DissectorError, message)) + /** Macro used for assertions in dissectors; it doesn't abort, it just * throws a DissectorError exception, with the assertion failure * message as a parameter, so that it can show up in the protocol tree. + * + * @param expression expression to test in the assertion */ #define DISSECTOR_ASSERT(expression) \ ((void) ((expression) ? 0 : \ @@ -89,7 +104,7 @@ typedef struct _protocol protocol_t; #define __DISSECTOR_ASSERT_STRINGIFY(s) # s #define __DISSECTOR_ASSERT(expression, file, lineno) \ - (THROW_MESSAGE(DissectorError, \ + (REPORT_DISSECTOR_BUG( \ g_strdup_printf("%s:%u: failed assertion \"%s\"", \ file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression))))