From 147ca4568379ea400b9a7577a468908cd8bcc92f Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 21 Dec 2014 16:09:15 -0800 Subject: [PATCH] Improve the message for "this field has an integral type" assertions. (Along the lines of provious changes.) Change-Id: I22d76f22400d4a93242392ff4688acc753eb0039 Reviewed-on: https://code.wireshark.org/review/5961 Reviewed-by: Guy Harris --- epan/proto.c | 6 +++--- epan/proto.h | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/epan/proto.c b/epan/proto.c index cb2a00c183..9e17ea7330 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -7628,7 +7628,7 @@ proto_tree_add_bitmask(proto_tree *parent_tree, tvbuff_t *tvb, int len; PROTO_REGISTRAR_GET_NTH(hf_hdr,hf); - DISSECTOR_ASSERT(IS_FT_INT(hf->type) || IS_FT_UINT(hf->type)); + DISSECTOR_ASSERT_FIELD_TYPE_IS_INTEGRAL(hf); len = ftype_length(hf->type); if (parent_tree) { @@ -7652,7 +7652,7 @@ proto_tree_add_bitmask_with_flags(proto_tree *parent_tree, tvbuff_t *tvb, const int len; PROTO_REGISTRAR_GET_NTH(hf_hdr,hf); - DISSECTOR_ASSERT(IS_FT_INT(hf->type) || IS_FT_UINT(hf->type)); + DISSECTOR_ASSERT_FIELD_TYPE_IS_INTEGRAL(hf); len = ftype_length(hf->type); if (parent_tree) { @@ -7688,7 +7688,7 @@ proto_tree_add_bitmask_len(proto_tree *parent_tree, tvbuff_t *tvb, guint32 decodable_value; PROTO_REGISTRAR_GET_NTH(hf_hdr, hf); - DISSECTOR_ASSERT(IS_FT_INT(hf->type) || IS_FT_UINT(hf->type)); + DISSECTOR_ASSERT_FIELD_TYPE_IS_INTEGRAL(hf); decodable_offset = offset; decodable_len = MIN(len, (guint) ftype_length(hf->type)); diff --git a/epan/proto.h b/epan/proto.h index bb80610f8b..9e3ab45c2e 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -249,6 +249,15 @@ WS_DLL_PUBLIC WS_MSVC_NORETURN void proto_report_dissector_bug(const char *messa __DISSECTOR_ASSERT_FIELD_TYPE ((hfinfo), t))) \ __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT((hfinfo)->type == t) +#define DISSECTOR_ASSERT_FIELD_TYPE_IS_INTEGRAL(hfinfo) \ + ((void) ((IS_FT_INT((hfinfo)->type) || \ + IS_FT_UINT((hfinfo)->type)) ? (void)0 : \ + REPORT_DISSECTOR_BUG( \ + ep_strdup_printf("%s:%u: field %s is not of an FT_{U}INTn type", \ + __FILE__, __LINE__, (hfinfo)->abbrev)))) \ + __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(IS_FT_INT((hfinfo)->type) || \ + IS_FT_UINT((hfinfo)->type)) + #define DISSECTOR_ASSERT_FIELD_TYPE_IS_TIME(hfinfo) \ ((void) (((hfinfo)->type == FT_ABSOLUTE_TIME || \ (hfinfo)->type == FT_RELATIVE_TIME) ? (void)0 : \