diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2016-02-06 12:28:16 +0100 |
---|---|---|
committer | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2016-02-06 13:27:59 +0000 |
commit | 47fc7ffcb0eb69f22ec54d698b6a7269c55035c6 (patch) | |
tree | 40343a5be5a25a2e7eab1d5fcab489e9911249c5 /asn1/pres/packet-pres-template.c | |
parent | a86e2107221024745fd8b2a3a0ed5e0fe9ba67f1 (diff) |
asn1: Cleanup space usage
Fix space issues in some ASN.1 dissectors.
Change-Id: I4ceccfbe9a13c93fc91821d1bfe4b7d6bb39c435
Reviewed-on: https://code.wireshark.org/review/13791
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'asn1/pres/packet-pres-template.c')
-rw-r--r-- | asn1/pres/packet-pres-template.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/asn1/pres/packet-pres-template.c b/asn1/pres/packet-pres-template.c index f0ec1cee41..86d4ed192a 100644 --- a/asn1/pres/packet-pres-template.c +++ b/asn1/pres/packet-pres-template.c @@ -134,7 +134,7 @@ register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, const char *oid) pres_ctx_oid_t *pco, *tmppco; conversation_t *conversation; - if(!oid){ + if (!oid) { /* we did not get any oid name, malformed packet? */ return; } @@ -144,8 +144,7 @@ register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, const char *oid) pco->oid=wmem_strdup(wmem_file_scope(), oid); if (pinfo->ptype == PT_TCP) { conversation = find_conversation_ext_from_pinfo(pinfo); - } - else { + } else { conversation = find_conversation(pinfo->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0); } @@ -157,9 +156,8 @@ register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, const char *oid) /* if this ctx already exists, remove the old one first */ tmppco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, pco); - if(tmppco){ + if (tmppco) { g_hash_table_remove(pres_ctx_oid_table, tmppco); - } g_hash_table_insert(pres_ctx_oid_table, pco, pco); } @@ -191,7 +189,7 @@ find_oid_by_pres_ctx_id(packet_info *pinfo, guint32 idx) pco.ctx_id=idx; if (pinfo->ptype == PT_TCP) { conversation = find_conversation_ext_from_pinfo(pinfo); - }else{ + } else { conversation = find_conversation(pinfo->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0); } @@ -202,7 +200,7 @@ find_oid_by_pres_ctx_id(packet_info *pinfo, guint32 idx) } tmppco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, &pco); - if(tmppco){ + if (tmppco) { return tmppco->oid; } @@ -246,13 +244,13 @@ dissect_ppdu(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, st asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* do we have spdu type from the session dissector? */ - if( local_session == NULL ){ + if (local_session == NULL) { proto_tree_add_expert(tree, pinfo, &ei_pres_wrong_spdu_type, tvb, offset, -1); return 0; } session = local_session; - if(session->spdu_type == 0 ){ + if (session->spdu_type == 0) { proto_tree_add_expert_format(tree, pinfo, &ei_pres_wrong_spdu_type, tvb, offset, -1, "Internal error:wrong spdu type %x from session dissector.",session->spdu_type); return 0; @@ -267,7 +265,7 @@ dissect_ppdu(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, st ti = proto_tree_add_item(tree, proto_pres, tvb, offset, -1, ENC_NA); pres_tree = proto_item_add_subtree(ti, ett_pres); - switch(session->spdu_type){ + switch (session->spdu_type) { case SES_CONNECTION_REQUEST: offset = dissect_pres_CP_type(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_CP_type); break; @@ -311,7 +309,7 @@ dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* d /* first, try to check length */ /* do we have at least 4 bytes */ - if (!tvb_bytes_exist(tvb, 0, 4)){ + if (!tvb_bytes_exist(tvb, 0, 4)) { if (session && session->spdu_type != SES_MAJOR_SYNC_POINT) { proto_tree_add_item(parent_tree, hf_pres_user_data, tvb, offset, tvb_reported_length_remaining(tvb,offset), ENC_NA); @@ -325,16 +323,14 @@ dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* d /* if the session unit-data packet then we process it */ /* as a connectionless presentation protocol unit data */ - if(session && session->spdu_type == CLSES_UNIT_DATA) - { + if (session && session->spdu_type == CLSES_UNIT_DATA) { proto_tree * clpres_tree = NULL; proto_item *ti; col_set_str(pinfo->cinfo, COL_PROTOCOL, "CL-PRES"); col_clear(pinfo->cinfo, COL_INFO); - if (parent_tree) - { + if (parent_tree) { ti = proto_tree_add_item(parent_tree, proto_clpres, tvb, offset, -1, ENC_NA); clpres_tree = proto_item_add_subtree(ti, ett_pres); } @@ -362,12 +358,12 @@ dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* d return tvb_captured_length(tvb); } - while (tvb_reported_length_remaining(tvb, offset) > 0){ + while (tvb_reported_length_remaining(tvb, offset) > 0) { old_offset = offset; offset = dissect_ppdu(tvb, offset, pinfo, parent_tree, session); - if(offset <= old_offset){ - proto_tree_add_expert(parent_tree, pinfo, &ei_pres_invalid_offset, tvb, offset, -1); - break; + if (offset <= old_offset) { + proto_tree_add_expert(parent_tree, pinfo, &ei_pres_invalid_offset, tvb, offset, -1); + break; } } |