diff options
author | Michael Mann <mmann78@netscape.net> | 2017-05-24 23:20:54 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-05-25 06:14:45 +0000 |
commit | d962e7ae71a856594ccc8be7ebd187e056d6f1e4 (patch) | |
tree | 3603f6c6f7a599c32f197a8484dac2e8fc5eb43f /epan/proto.c | |
parent | 45dbd239ef55f87741f782950a02cc998d48508a (diff) |
Simplify proto_tree_add_bytes_format[_value]
Call proto_tree_add_bytes first so it can do all of the basic
field checks that were being duplicated.
Change-Id: Idc9a3cbf9498aa612a39cc80e3381eba52ce9fa4
Reviewed-on: https://code.wireshark.org/review/21750
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/proto.c')
-rw-r--r-- | epan/proto.c | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/epan/proto.c b/epan/proto.c index c9309fce59..8d3d455e49 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -3317,23 +3317,11 @@ proto_tree_add_bytes_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb, { proto_item *pi; va_list ap; - header_field_info *hfinfo; - gint item_length; - - PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo); - get_hfi_length(hfinfo, tvb, start, &length, &item_length); - test_length(hfinfo, tvb, start, item_length); - CHECK_FOR_NULL_TREE(tree); + if (start_ptr == NULL) + start_ptr = tvb_get_ptr(tvb, start, length); - TRY_TO_FAKE_THIS_ITEM(tree, hfindex, hfinfo); - - if (start_ptr) - pi = proto_tree_add_bytes(tree, hfindex, tvb, start, length, - start_ptr); - else - pi = proto_tree_add_bytes(tree, hfindex, tvb, start, length, - tvb_get_ptr(tvb, start, length)); + pi = proto_tree_add_bytes(tree, hfindex, tvb, start, length, start_ptr); va_start(ap, format); proto_tree_set_representation_value(pi, format, ap); @@ -3349,23 +3337,11 @@ proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, { proto_item *pi; va_list ap; - header_field_info *hfinfo; - gint item_length; - - PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo); - get_hfi_length(hfinfo, tvb, start, &length, &item_length); - test_length(hfinfo, tvb, start, item_length); - CHECK_FOR_NULL_TREE(tree); + if (start_ptr == NULL) + start_ptr = tvb_get_ptr(tvb, start, length); - TRY_TO_FAKE_THIS_ITEM(tree, hfindex, hfinfo); - - if (start_ptr) - pi = proto_tree_add_bytes(tree, hfindex, tvb, start, length, - start_ptr); - else - pi = proto_tree_add_bytes(tree, hfindex, tvb, start, length, - tvb_get_ptr(tvb, start, length)); + pi = proto_tree_add_bytes(tree, hfindex, tvb, start, length, start_ptr); TRY_TO_FAKE_THIS_REPR(pi); |