diff options
author | Guy Harris <guy@alum.mit.edu> | 2005-01-17 00:18:39 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2005-01-17 00:18:39 +0000 |
commit | 2617e403563e10643a84e0af550642a2e6b7c751 (patch) | |
tree | 8c178b993b579bfd938b463218000944c7275c8e /epan/proto.h | |
parent | 2bdef3c1229d5c492c0e574135b3ef4589647b2a (diff) |
Add a REPORT_DISSECTOR_BUG() macro to let caller-specified messages be
used in DissectorError exceptions.
svn path=/trunk/; revision=13079
Diffstat (limited to 'epan/proto.h')
-rw-r--r-- | epan/proto.h | 17 |
1 files changed, 16 insertions, 1 deletions
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)))) |