From fac8f1f1bd4b0cb41bcce5e9777376ad3c119f45 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 10 Jul 2016 18:41:23 +0200 Subject: pvfs2: clean up dissect_pvfs_distribution() remove unnecessary variable initializers remove an unnecessary if (tree) check Change-Id: I4c5326c11efe4fe38fb606a45ca7674484e9421c Reviewed-on: https://code.wireshark.org/review/16371 Reviewed-by: Martin Kaiser --- epan/dissectors/packet-pvfs2.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/epan/dissectors/packet-pvfs2.c b/epan/dissectors/packet-pvfs2.c index 16e9bff1e1..563ed38082 100644 --- a/epan/dissectors/packet-pvfs2.c +++ b/epan/dissectors/packet-pvfs2.c @@ -1147,11 +1147,12 @@ int dissect_pvfs_uint64(tvbuff_t *tvb, proto_tree *tree, int offset, static int dissect_pvfs_distribution(tvbuff_t *tvb, proto_tree *tree, int offset) { - proto_item *dist_item = NULL; - proto_tree *dist_tree = NULL; - guint32 distlen = 0; - char *tmpstr = NULL; + proto_item *dist_item; + proto_tree *dist_tree; + guint32 distlen; + char *tmpstr; guint8 issimplestripe = 0; + guint32 total_len; /* Get distribution name length */ distlen = tvb_get_letohl(tvb, offset); @@ -1159,28 +1160,23 @@ dissect_pvfs_distribution(tvbuff_t *tvb, proto_tree *tree, int offset) /* Get distribution name */ tmpstr = (char *) tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 4, distlen, ENC_ASCII); - if (tree) - { - guint32 total_len; - - /* 'distlen' does not include the NULL terminator */ - total_len = roundup8(4 + distlen + 1); - - if (((distlen + 1) == PVFS_DIST_SIMPLE_STRIPE_NAME_SIZE) && - (g_ascii_strncasecmp(tmpstr, PVFS_DIST_SIMPLE_STRIPE_NAME, - distlen) == 0)) - { - /* Parameter for 'simple_stripe' is 8 bytes */ - total_len += 8; + /* 'distlen' does not include the NULL terminator */ + total_len = roundup8(4 + distlen + 1); - issimplestripe = 1; - } + if (((distlen + 1) == PVFS_DIST_SIMPLE_STRIPE_NAME_SIZE) && + (g_ascii_strncasecmp(tmpstr, PVFS_DIST_SIMPLE_STRIPE_NAME, + distlen) == 0)) + { + /* Parameter for 'simple_stripe' is 8 bytes */ + total_len += 8; - dist_item = proto_tree_add_string(tree, hf_pvfs_distribution, tvb, offset, - total_len + 8, tmpstr); - dist_tree = proto_item_add_subtree(dist_item, ett_pvfs_distribution); + issimplestripe = 1; } + dist_item = proto_tree_add_string(tree, hf_pvfs_distribution, + tvb, offset, total_len + 8, tmpstr); + dist_tree = proto_item_add_subtree(dist_item, ett_pvfs_distribution); + /* io_dist */ offset = dissect_pvfs_string(tvb, dist_tree, hf_pvfs_io_dist, offset, NULL); -- cgit v1.2.3