Clean up checking for invalid field definitions.
Add comments to indicate what types of display information various field types are allowed. Make the error messages for fields that only allow some particular display information types specific to those types, rather than saying "no field information allowed". This also gets rid of some fallthroughs, one of which allows BASE_PROTOCOL_INFO for floating-point types, which makes no sense.
This commit is contained in:
parent
a8c8ee6908
commit
1e27fe59fd
42
epan/proto.c
42
epan/proto.c
|
@ -8221,6 +8221,12 @@ tmp_fld_check_assert(header_field_info *hfinfo)
|
|||
*/
|
||||
if (hfinfo->strings != NULL) {
|
||||
switch (hfinfo->type) {
|
||||
|
||||
/*
|
||||
* These types are allowed to support display value_strings,
|
||||
* value64_strings, the extended versions of the previous
|
||||
* two, range strings, or unit strings.
|
||||
*/
|
||||
case FT_CHAR:
|
||||
case FT_UINT8:
|
||||
case FT_UINT16:
|
||||
|
@ -8240,21 +8246,41 @@ tmp_fld_check_assert(header_field_info *hfinfo)
|
|||
case FT_INT64:
|
||||
case FT_BOOLEAN:
|
||||
case FT_PROTOCOL:
|
||||
break;
|
||||
|
||||
/*
|
||||
* This is allowed to have a value of type
|
||||
* enum ft_framenum_type to indicate what relationship
|
||||
* the frame in question has to the frame in which
|
||||
* the field is put.
|
||||
*/
|
||||
case FT_FRAMENUM:
|
||||
break;
|
||||
|
||||
/*
|
||||
* These types are allowed to support only unit strings.
|
||||
*/
|
||||
case FT_FLOAT:
|
||||
case FT_DOUBLE:
|
||||
//allowed to support string if its a unit decsription
|
||||
if (hfinfo->display & BASE_UNIT_STRING)
|
||||
break;
|
||||
if (!(hfinfo->display & BASE_UNIT_STRING)) {
|
||||
REPORT_DISSECTOR_BUG("Field '%s' (%s) has a non-unit-strings 'strings' value but is of type %s"
|
||||
" (which is only allowed to have unit strings)",
|
||||
hfinfo->name, hfinfo->abbrev, ftype_name(hfinfo->type));
|
||||
}
|
||||
break;
|
||||
|
||||
//fallthrough
|
||||
/*
|
||||
* This type is only allowed to support a string if it's
|
||||
* a protocol (for pinos).
|
||||
*/
|
||||
case FT_BYTES:
|
||||
//allowed to support string if its a protocol (for pinos)
|
||||
if (hfinfo->display & BASE_PROTOCOL_INFO)
|
||||
break;
|
||||
if (!(hfinfo->display & BASE_PROTOCOL_INFO)) {
|
||||
REPORT_DISSECTOR_BUG("Field '%s' (%s) has a non-protocol-info 'strings' value but is of type %s"
|
||||
" (which is only allowed to have protocol-info strings)",
|
||||
hfinfo->name, hfinfo->abbrev, ftype_name(hfinfo->type));
|
||||
}
|
||||
break;
|
||||
|
||||
//fallthrough
|
||||
default:
|
||||
REPORT_DISSECTOR_BUG("Field '%s' (%s) has a 'strings' value but is of type %s"
|
||||
" (which is not allowed to have strings)",
|
||||
|
|
Loading…
Reference in New Issue