diff options
author | Michael Mann <mmann78@netscape.net> | 2016-06-26 10:52:37 -0400 |
---|---|---|
committer | Pascal Quantin <pascal.quantin@gmail.com> | 2016-06-27 15:20:06 +0000 |
commit | 2ab415579491e4bc66ea58627bda504cae833b9e (patch) | |
tree | 0f7f8eaa4bd9d90c8f6066036522ef0fc65d137d /epan/dissectors/packet-artnet.c | |
parent | 8c37621ca733a24a972e3e069a537c06e650f435 (diff) |
tvb_get_string_enc + proto_tree_add_item = proto_tree_add_item_ret_string
Also some other tricks to remove unnecessary tvb_get_string_enc calls.
Change-Id: I2f40d9175b6c0bb0b1364b4089bfaa287edf0914
Reviewed-on: https://code.wireshark.org/review/16158
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-artnet.c')
-rw-r--r-- | epan/dissectors/packet-artnet.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/epan/dissectors/packet-artnet.c b/epan/dissectors/packet-artnet.c index 2723a111a8..90b29c2e6e 100644 --- a/epan/dissectors/packet-artnet.c +++ b/epan/dissectors/packet-artnet.c @@ -3172,34 +3172,25 @@ dissect_artnet_file_fn_reply(tvbuff_t *tvb _U_, guint offset, proto_tree *tree _ static int dissect_artnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { - gint offset = 0; - guint size; - guint16 opcode; - proto_tree *ti = NULL, *hi = NULL, *si = NULL, *artnet_tree = NULL, *artnet_header_tree = NULL; + gint offset = 0; + guint size; + guint16 opcode; + const guint8 *header; + proto_tree *ti, *hi, *si = NULL, *artnet_tree, *artnet_header_tree; col_set_str(pinfo->cinfo, COL_PROTOCOL, "ARTNET"); col_clear(pinfo->cinfo, COL_INFO); - if (tree) { - ti = proto_tree_add_item(tree, proto_artnet, tvb, offset, -1, ENC_NA); - artnet_tree = proto_item_add_subtree(ti, ett_artnet); - - hi = proto_tree_add_item(artnet_tree, - hf_artnet_header, - tvb, - offset, - ARTNET_HEADER_LENGTH , - ENC_NA); + ti = proto_tree_add_item(tree, proto_artnet, tvb, offset, -1, ENC_NA); + artnet_tree = proto_item_add_subtree(ti, ett_artnet); - artnet_header_tree = proto_item_add_subtree(hi, ett_artnet); - } + hi = proto_tree_add_item(artnet_tree, hf_artnet_header, tvb, + offset, ARTNET_HEADER_LENGTH, ENC_NA); + artnet_header_tree = proto_item_add_subtree(hi, ett_artnet); - col_append_fstr(pinfo->cinfo, COL_INFO, "%s", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 8, ENC_ASCII|ENC_NA)); - if (tree) { - proto_tree_add_item(artnet_header_tree, hf_artnet_header_id, - tvb, offset, 8, ENC_ASCII|ENC_NA); - } + proto_tree_add_item_ret_string(artnet_header_tree, hf_artnet_header_id, + tvb, offset, 8, ENC_ASCII|ENC_NA, wmem_packet_scope(), &header); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s", header); offset += 8; opcode = tvb_get_letohs(tvb, offset); |