diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2015-08-13 22:44:29 +0200 |
---|---|---|
committer | Martin Kaiser <wireshark@kaiser.cx> | 2015-08-17 20:26:08 +0000 |
commit | 41cb3bdc54aeac50b021db0360505559090f152e (patch) | |
tree | 5cb90c4fb038b6d6ba021aac4e8e7e24d15f8c54 /epan/dissectors/packet-h1.c | |
parent | c78d7c8aa84361bf13fa0816dfe16f9a46fccb3a (diff) |
h1: remove if (tree) checks, indent according to the modelines
Change-Id: I878aa23b5d718653b9039aeb94a0ece88c9c03cf
Reviewed-on: https://code.wireshark.org/review/10079
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Diffstat (limited to 'epan/dissectors/packet-h1.c')
-rw-r--r-- | epan/dissectors/packet-h1.c | 175 |
1 files changed, 83 insertions, 92 deletions
diff --git a/epan/dissectors/packet-h1.c b/epan/dissectors/packet-h1.c index 9e2e6f72ce..9d2139d123 100644 --- a/epan/dissectors/packet-h1.c +++ b/epan/dissectors/packet-h1.c @@ -96,13 +96,13 @@ static gboolean dissect_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, { tvbuff_t *next_tvb; - proto_tree *h1_tree = NULL; + proto_tree *h1_tree; proto_item *ti; - proto_tree *opcode_tree = NULL; - proto_tree *org_tree = NULL; - proto_tree *response_tree = NULL; - proto_tree *empty_tree = NULL; + proto_tree *opcode_tree; + proto_tree *org_tree; + proto_tree *response_tree; + proto_tree *empty_tree; unsigned int position = 3; unsigned int offset=0; @@ -121,106 +121,97 @@ static gboolean dissect_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, col_set_str (pinfo->cinfo, COL_PROTOCOL, "H1"); col_set_str(pinfo->cinfo, COL_INFO, "S5: "); - if (tree) - { - ti = proto_tree_add_item (tree, proto_h1, tvb, offset, 16, ENC_NA); - h1_tree = proto_item_add_subtree (ti, ett_h1); - proto_tree_add_uint (h1_tree, hf_h1_header, tvb, offset, 2, - tvb_get_ntohs(tvb,offset)); - proto_tree_add_uint (h1_tree, hf_h1_len, tvb, offset + 2, 1, - tvb_get_guint8(tvb,offset+2)); - } + + ti = proto_tree_add_item (tree, proto_h1, tvb, offset, 16, ENC_NA); + h1_tree = proto_item_add_subtree (ti, ett_h1); + proto_tree_add_uint (h1_tree, hf_h1_header, tvb, offset, 2, + tvb_get_ntohs(tvb,offset)); + proto_tree_add_uint (h1_tree, hf_h1_len, tvb, offset + 2, 1, + tvb_get_guint8(tvb,offset+2)); while (position < tvb_get_guint8(tvb,offset+2)) { switch (tvb_get_guint8(tvb,offset + position)) { case OPCODE_BLOCK: - if (h1_tree) - { - ti = proto_tree_add_uint (h1_tree, hf_h1_opfield, tvb, - offset + position, - tvb_get_guint8(tvb,offset+position+1), - tvb_get_guint8(tvb,offset+position)); - opcode_tree = proto_item_add_subtree (ti, ett_opcode); - proto_tree_add_uint (opcode_tree, hf_h1_oplen, tvb, - offset + position + 1, 1, - tvb_get_guint8(tvb,offset + position + 1)); - proto_tree_add_uint (opcode_tree, hf_h1_opcode, tvb, - offset + position + 2, 1, - tvb_get_guint8(tvb,offset + position + 2)); - } - - col_append_str (pinfo->cinfo, COL_INFO, - val_to_str (tvb_get_guint8(tvb,offset + position + 2), - opcode_vals,"Unknown Opcode (0x%2.2x)")); + ti = proto_tree_add_uint (h1_tree, hf_h1_opfield, tvb, + offset + position, + tvb_get_guint8(tvb,offset+position+1), + tvb_get_guint8(tvb,offset+position)); + opcode_tree = proto_item_add_subtree (ti, ett_opcode); + proto_tree_add_uint (opcode_tree, hf_h1_oplen, tvb, + offset + position + 1, 1, + tvb_get_guint8(tvb,offset + position + 1)); + proto_tree_add_uint (opcode_tree, hf_h1_opcode, tvb, + offset + position + 2, 1, + tvb_get_guint8(tvb,offset + position + 2)); + + col_append_str (pinfo->cinfo, COL_INFO, + val_to_str (tvb_get_guint8(tvb,offset + position + 2), + opcode_vals,"Unknown Opcode (0x%2.2x)")); break; + case REQUEST_BLOCK: - if (h1_tree) - { - ti = proto_tree_add_uint (h1_tree, hf_h1_requestblock, tvb, - offset + position, - tvb_get_guint8(tvb,offset + position + 1), - tvb_get_guint8(tvb,offset + position)); - org_tree = proto_item_add_subtree (ti, ett_org); - proto_tree_add_uint (org_tree, hf_h1_requestlen, tvb, - offset + position + 1, 1, - tvb_get_guint8(tvb,offset + position+1)); - proto_tree_add_uint (org_tree, hf_h1_org, tvb, - offset + position + 2, 1, - tvb_get_guint8(tvb,offset + position+2)); - proto_tree_add_uint (org_tree, hf_h1_dbnr, tvb, - offset + position + 3, 1, - tvb_get_guint8(tvb,offset + position+3)); - proto_tree_add_uint (org_tree, hf_h1_dwnr, tvb, - offset + position + 4, 2, - tvb_get_ntohs(tvb,offset+position+4)); - proto_tree_add_int (org_tree, hf_h1_dlen, tvb, - offset + position + 6, 2, - tvb_get_ntohs(tvb,offset+position+6)); - } - col_append_fstr (pinfo->cinfo, COL_INFO, " %s %d", - val_to_str (tvb_get_guint8(tvb,offset + position + 2), - org_vals,"Unknown Type (0x%2.2x)"), - tvb_get_guint8(tvb,offset + position + 3)); - col_append_fstr (pinfo->cinfo, COL_INFO, " DW %d", - tvb_get_ntohs(tvb,offset+position+4)); - col_append_fstr (pinfo->cinfo, COL_INFO, " Count %d", - tvb_get_ntohs(tvb,offset+position+6)); + ti = proto_tree_add_uint (h1_tree, hf_h1_requestblock, tvb, + offset + position, + tvb_get_guint8(tvb,offset + position + 1), + tvb_get_guint8(tvb,offset + position)); + org_tree = proto_item_add_subtree (ti, ett_org); + proto_tree_add_uint (org_tree, hf_h1_requestlen, tvb, + offset + position + 1, 1, + tvb_get_guint8(tvb,offset + position+1)); + proto_tree_add_uint (org_tree, hf_h1_org, tvb, + offset + position + 2, 1, + tvb_get_guint8(tvb,offset + position+2)); + proto_tree_add_uint (org_tree, hf_h1_dbnr, tvb, + offset + position + 3, 1, + tvb_get_guint8(tvb,offset + position+3)); + proto_tree_add_uint (org_tree, hf_h1_dwnr, tvb, + offset + position + 4, 2, + tvb_get_ntohs(tvb,offset+position+4)); + proto_tree_add_int (org_tree, hf_h1_dlen, tvb, + offset + position + 6, 2, + tvb_get_ntohs(tvb,offset+position+6)); + + col_append_fstr (pinfo->cinfo, COL_INFO, " %s %d", + val_to_str (tvb_get_guint8(tvb,offset + position + 2), + org_vals,"Unknown Type (0x%2.2x)"), + tvb_get_guint8(tvb,offset + position + 3)); + col_append_fstr (pinfo->cinfo, COL_INFO, " DW %d", + tvb_get_ntohs(tvb,offset+position+4)); + col_append_fstr (pinfo->cinfo, COL_INFO, " Count %d", + tvb_get_ntohs(tvb,offset+position+6)); break; + case RESPONSE_BLOCK: - if (h1_tree) - { - ti = proto_tree_add_uint (h1_tree, hf_h1_response, tvb, - offset + position, - tvb_get_guint8(tvb,offset + position + 1), - tvb_get_guint8(tvb,offset + position)); - response_tree = proto_item_add_subtree (ti, ett_response); - proto_tree_add_uint (response_tree, hf_h1_response_len, tvb, - offset + position + 1, 1, - tvb_get_guint8(tvb,offset + position+1)); - proto_tree_add_uint (response_tree, hf_h1_response_value, tvb, - offset + position + 2, 1, - tvb_get_guint8(tvb,offset + position+2)); - } - col_append_fstr (pinfo->cinfo, COL_INFO, " %s", - val_to_str (tvb_get_guint8(tvb,offset + position + 2), - returncode_vals,"Unknown Returncode (0x%2.2x")); + ti = proto_tree_add_uint (h1_tree, hf_h1_response, tvb, + offset + position, + tvb_get_guint8(tvb,offset + position + 1), + tvb_get_guint8(tvb,offset + position)); + response_tree = proto_item_add_subtree (ti, ett_response); + proto_tree_add_uint (response_tree, hf_h1_response_len, tvb, + offset + position + 1, 1, + tvb_get_guint8(tvb,offset + position+1)); + proto_tree_add_uint (response_tree, hf_h1_response_value, tvb, + offset + position + 2, 1, + tvb_get_guint8(tvb,offset + position+2)); + + col_append_fstr (pinfo->cinfo, COL_INFO, " %s", + val_to_str (tvb_get_guint8(tvb,offset + position + 2), + returncode_vals,"Unknown Returncode (0x%2.2x")); break; + case EMPTY_BLOCK: - if (h1_tree) - { - ti = proto_tree_add_uint (h1_tree, hf_h1_empty, tvb, - offset + position, - tvb_get_guint8(tvb,offset + position + 1), - tvb_get_guint8(tvb,offset + position)); - empty_tree = proto_item_add_subtree (ti, ett_empty); - - proto_tree_add_uint (empty_tree, hf_h1_empty_len, tvb, - offset + position + 1, 1, - tvb_get_guint8(tvb,offset + position+1)); - } + ti = proto_tree_add_uint (h1_tree, hf_h1_empty, tvb, + offset + position, + tvb_get_guint8(tvb,offset + position + 1), + tvb_get_guint8(tvb,offset + position)); + empty_tree = proto_item_add_subtree (ti, ett_empty); + proto_tree_add_uint (empty_tree, hf_h1_empty_len, tvb, + offset + position + 1, 1, + tvb_get_guint8(tvb,offset + position+1)); break; + default: /* This is not a valid telegram. So cancel dissection and try the next dissector */ |