From dea13b3cac2a99beb1828cba00c6bd36231c7365 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Mon, 5 Jun 2017 16:14:01 +0200 Subject: profinet: use proto_tree_add_item_ret_(u)int profinet has a number of internal functions that add an item to the tree and read its value. For 32bit integers, this is exactly what proto_tree_add_item_ret_(u)int do. Just call those functions. (We could do the same for 8 and 16bit values. We'd need a temporary value then and the code wouldn't be much easier than it is now.) Change-Id: I98fc70ced2dc5a552235a476d40a4275f3b3bd38 Reviewed-on: https://code.wireshark.org/review/21965 Petri-Dish: Martin Kaiser Tested-by: Petri Dish Buildbot Reviewed-by: Martin Kaiser --- plugins/profinet/packet-pn.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'plugins') diff --git a/plugins/profinet/packet-pn.c b/plugins/profinet/packet-pn.c index 6cde573b42..0399cf9253 100644 --- a/plugins/profinet/packet-pn.c +++ b/plugins/profinet/packet-pn.c @@ -105,13 +105,9 @@ int dissect_pn_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *tree, int hfindex, guint32 *pdata) { - guint32 data; - - data = tvb_get_ntohl (tvb, offset); + proto_tree_add_item_ret_uint(tree, hfindex, + tvb, offset, 4, ENC_BIG_ENDIAN, pdata); - proto_tree_add_uint(tree, hfindex, tvb, offset, 4, data); - if (pdata) - *pdata = data; return offset+4; } @@ -135,13 +131,9 @@ int dissect_pn_int32(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *tree, int hfindex, gint32 *pdata) { - gint32 data; + proto_tree_add_item_ret_int(tree, hfindex, + tvb, offset, 4, ENC_BIG_ENDIAN, pdata); - data = tvb_get_ntohl (tvb, offset); - - proto_tree_add_int(tree, hfindex, tvb, offset, 4, data); - if (pdata) - *pdata = data; return offset + 4; } -- cgit v1.2.3