diff options
author | Evan Huus <eapache@gmail.com> | 2014-05-25 11:13:04 -0400 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-05-25 18:12:00 +0000 |
commit | 08ce84ebbe91eaaccd8bbf8c8d43c8cecfc7945a (patch) | |
tree | 1ee03c6b55a52e996fbf1ec25befe127cb071385 /epan | |
parent | c4ead251da7199cfd746d378c51eb8c30d09a6ba (diff) |
Grab-bag of dead initializers and two actual bugs.
All caught by cppcheck. The two (semi)-interesting bugs are:
- in asn1/atn-cpdlc/packet-atn-cpdlc-template.c where the break statement should
have been inside the brace, causing potential control-flow weirdness with
exceptions
- in epan/dissectors/packet-ieee80211.c where the bounds check for tag_len did
not match the expert info given
Change-Id: Ie173fb8d917aabb9b4571435d671d6f16e1c7569
Reviewed-on: https://code.wireshark.org/review/1793
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-asterix.c | 7 | ||||
-rw-r--r-- | epan/dissectors/packet-atn-cm.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-atn-cpdlc.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-batadv.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-dcerpc-netlogon.c | 1 | ||||
-rw-r--r-- | epan/dissectors/packet-dcerpc-nt.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-dcp-etsi.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-ieee80211.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-lisp.c | 20 | ||||
-rw-r--r-- | epan/dissectors/packet-mac-lte.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-mongo.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-openflow_v5.c | 1 |
12 files changed, 29 insertions, 32 deletions
diff --git a/epan/dissectors/packet-asterix.c b/epan/dissectors/packet-asterix.c index 759e0f0b76..a2b3649851 100644 --- a/epan/dissectors/packet-asterix.c +++ b/epan/dissectors/packet-asterix.c @@ -7005,15 +7005,13 @@ static void dissect_asterix_packet (tvbuff_t *tvb, proto_tree *tree) guint i; guint8 category; guint16 length; - proto_item *asterix_packet_item = NULL; - proto_tree *asterix_packet_tree = NULL; + proto_item *asterix_packet_item; + proto_tree *asterix_packet_tree; for (i = 0; i < tvb_reported_length (tvb); i += length + 3) { category = tvb_get_guint8 (tvb, i); length = (tvb_get_guint8 (tvb, i + 1) << 8) + tvb_get_guint8 (tvb, i + 2) - 3; /* -3 for category and length */ - asterix_packet_item = NULL; - asterix_packet_tree = NULL; asterix_packet_item = proto_tree_add_item (tree, proto_asterix, tvb, i, length + 3, ENC_NA); proto_item_append_text (asterix_packet_item, ", Category %03d", category); asterix_packet_tree = proto_item_add_subtree (asterix_packet_item, ett_asterix); @@ -7117,7 +7115,6 @@ static void asterix_build_subtree (tvbuff_t *tvb, guint offset, proto_tree *pare if (field->part != NULL) { for (i = 0, inner_offset = 0, go_on = 1; go_on && field->part[i] != NULL; i++) { - value = G_GINT64_CONSTANT(0);; value = tvb_get_bits64 (tvb, offset * 8 + inner_offset, field->part[i]->bit_length, ENC_BIG_ENDIAN); if (field->part[i]->hf != NULL) { switch (field->part[i]->type) { diff --git a/epan/dissectors/packet-atn-cm.c b/epan/dissectors/packet-atn-cm.c index e7ca5a1278..d7fd33dd6c 100644 --- a/epan/dissectors/packet-atn-cm.c +++ b/epan/dissectors/packet-atn-cm.c @@ -641,9 +641,9 @@ dissect_atn_cm( proto_tree *tree, void *data _U_) { - int type = no_msg; - proto_item *ti = NULL; - proto_tree *sub_tree = NULL; + int type; + proto_item *ti; + proto_tree *sub_tree; ti = proto_tree_add_text( tree, diff --git a/epan/dissectors/packet-atn-cpdlc.c b/epan/dissectors/packet-atn-cpdlc.c index 5ff3d39e7f..e21ffa70c0 100644 --- a/epan/dissectors/packet-atn-cpdlc.c +++ b/epan/dissectors/packet-atn-cpdlc.c @@ -5415,7 +5415,7 @@ dissect_atn_cpdlc_heur( atn_conversation_t *atn_cv = NULL; volatile gboolean is_atn_cpdlc = FALSE; volatile gboolean is_pm = FALSE; - int type = no_msg; + int type; type = check_heur_msg_type(pinfo); @@ -5424,8 +5424,8 @@ dissect_atn_cpdlc_heur( TRY { dissect_ProtectedGroundPDUs_PDU(tvb, pinfo, NULL); is_atn_cpdlc = TRUE; - is_pm = TRUE;} - break; + is_pm = TRUE; + break;} CATCH_ALL{ is_atn_cpdlc = FALSE; is_pm = FALSE;} diff --git a/epan/dissectors/packet-batadv.c b/epan/dissectors/packet-batadv.c index 3dae4aef9c..1a52fc45d5 100644 --- a/epan/dissectors/packet-batadv.c +++ b/epan/dissectors/packet-batadv.c @@ -2238,7 +2238,7 @@ static void dissect_batadv_unicast_frag_v12(tvbuff_t *tvb, packet_info *pinfo, p proto_item *tf; struct unicast_frag_packet_v12 *unicast_frag_packeth; const guint8 *dest_addr, *orig_addr; - gboolean save_fragmented = FALSE; + gboolean save_fragmented; fragment_head *frag_msg = NULL; proto_tree *batadv_unicast_frag_tree = NULL, *flag_tree; @@ -2344,7 +2344,7 @@ static void dissect_batadv_unicast_frag_v14(tvbuff_t *tvb, packet_info *pinfo, p proto_item *tf; struct unicast_frag_packet_v14 *unicast_frag_packeth; const guint8 *dest_addr, *orig_addr; - gboolean save_fragmented = FALSE; + gboolean save_fragmented; fragment_head *frag_msg = NULL; proto_tree *batadv_unicast_frag_tree = NULL, *flag_tree; diff --git a/epan/dissectors/packet-dcerpc-netlogon.c b/epan/dissectors/packet-dcerpc-netlogon.c index 52527bd2b3..c2ad75935e 100644 --- a/epan/dissectors/packet-dcerpc-netlogon.c +++ b/epan/dissectors/packet-dcerpc-netlogon.c @@ -2502,7 +2502,6 @@ netlogon_dissect_netrserverreqchallenge_rqst(tvbuff_t *tvb, int offset, vars->next = NULL; generate_hash_key(pinfo,0,key,NULL); - existing_vars = NULL; existing_vars = (netlogon_auth_vars *)g_hash_table_lookup(netlogon_auths, key); if (!existing_vars) { debugprintf("Adding initial vars with this start packet = %d\n",vars->start); diff --git a/epan/dissectors/packet-dcerpc-nt.c b/epan/dissectors/packet-dcerpc-nt.c index 9101974cc0..d24c3ab6fc 100644 --- a/epan/dissectors/packet-dcerpc-nt.c +++ b/epan/dissectors/packet-dcerpc-nt.c @@ -82,7 +82,7 @@ dissect_ndr_datablob(tvbuff_t *tvb, int offset, packet_info *pinfo, { proto_item *item; guint3264 len; - proto_tree *subtree = tree; + proto_tree *subtree; item = proto_tree_add_text(tree, tvb, offset, 0, "%s", proto_registrar_get_name(hf_index)); diff --git a/epan/dissectors/packet-dcp-etsi.c b/epan/dissectors/packet-dcp-etsi.c index 3026592767..26ecf654f9 100644 --- a/epan/dissectors/packet-dcp-etsi.c +++ b/epan/dissectors/packet-dcp-etsi.c @@ -339,7 +339,7 @@ dissect_pft_fec_detailed(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, } } if(new_tvb && tvb_length(new_tvb) > 0) { - gboolean decoded = TRUE; + gboolean decoded; tvbuff_t *dtvb = NULL; const guint8 *input = tvb_get_ptr(new_tvb, 0, -1); guint32 reassembled_size = tvb_length(new_tvb); diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index d35d63d7fc..6ea6aabe22 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -10757,7 +10757,7 @@ dissect_vht_tx_pwr_envelope(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 opt_ie_cnt=0; guint8 i; - if (tag_len < 2 && tag_len <= 5) { + if (tag_len < 2 || tag_len > 5) { expert_add_info_format(pinfo, ti_len, &ei_ieee80211_tag_length, "VHT TX PWR Envelope IE length %u wrong, must be >= 2 and <= 5", tag_len); return offset; @@ -11434,7 +11434,7 @@ dissect_wapi_param_set(tvbuff_t *tvb, packet_info *pinfo, /* Parse the WAPI Parameter Set IE Here*/ proto_item *item; proto_tree *subtree; - guint16 loop_cnt, version = 1, akm_cnt = 1, ucast_cnt = 1, bkid_cnt = 1; + guint16 loop_cnt, version, akm_cnt = 1, ucast_cnt = 1, bkid_cnt = 1; guint8 akm_suite_type = 0, ucast_cipher_type = 0, mcast_cipher_type = 0; version = tvb_get_letohs(tvb, offset); diff --git a/epan/dissectors/packet-lisp.c b/epan/dissectors/packet-lisp.c index 2b77a43046..3c87d277d8 100644 --- a/epan/dissectors/packet-lisp.c +++ b/epan/dissectors/packet-lisp.c @@ -2101,11 +2101,11 @@ dissect_lisp_map_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tre guint16 addr_len = 0; gint offset = 0; guint16 flags; - gboolean mrep = FALSE; - gboolean smr = FALSE; - gboolean probe = FALSE; - gboolean pitr = FALSE; - gboolean smr_invoked = FALSE; + gboolean mrep; + gboolean smr; + gboolean probe; + gboolean pitr; + gboolean smr_invoked; guint8 itr_rec_cnt = 0; guint8 rec_cnt = 0; guint16 src_eid_afi; @@ -2350,7 +2350,7 @@ dissect_lisp_map_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tree) { int i; gint offset = 0; - gboolean probe = FALSE; + gboolean probe; guint8 flags; guint8 rec_cnt = 0; tvbuff_t *next_tvb; @@ -2437,8 +2437,8 @@ dissect_lisp_map_register(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tr tvbuff_t *next_tvb; guint16 authlen = 0; guint16 flags; - gboolean xtrid = FALSE; - gboolean rtr = FALSE; + gboolean xtrid; + gboolean rtr; /* Flags (1 bit) */ proto_tree_add_item(lisp_tree, hf_lisp_mreg_flags_pmr, tvb, offset, 3, ENC_BIG_ENDIAN); @@ -2550,8 +2550,8 @@ dissect_lisp_map_notify(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tree tvbuff_t *next_tvb; guint16 authlen = 0; guint16 flags; - gboolean xtrid = FALSE; - gboolean rtr = FALSE; + gboolean xtrid; + gboolean rtr; /* Flags defined in NAT Traversal draft (2 bits) */ flags = tvb_get_ntohs(tvb, offset); diff --git a/epan/dissectors/packet-mac-lte.c b/epan/dissectors/packet-mac-lte.c index 7b6775a165..02f5f51f17 100644 --- a/epan/dissectors/packet-mac-lte.c +++ b/epan/dissectors/packet-mac-lte.c @@ -1389,9 +1389,7 @@ static guint mac_lte_framenum_instance_hash_func(gconstpointer v) { const drx_state_key_t *p1 = (const drx_state_key_t*)v; - /* XXX which one return ? */ return p1->frameNumber + (p1->pdu_instance >> 8); - return GPOINTER_TO_UINT(v); } @@ -4275,6 +4273,10 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree curr_offset++; } } else { + /* XXX dead code? Expression is always false because + * the condition matches previous condition in the + * original if (so if it were true we'd never get + * to this 'else' block in the first place) */ if ((gint16)(computed_header_offset + 1 - curr_offset) != pdu_lengths[n]) { expert_add_info_format(pinfo, ephr_ti, &ei_mac_lte_control_element_size_invalid, "Control Element has an unexpected size (computed=%d, actual=%d)", diff --git a/epan/dissectors/packet-mongo.c b/epan/dissectors/packet-mongo.c index 574c1707ad..f0b80e6a38 100644 --- a/epan/dissectors/packet-mongo.c +++ b/epan/dissectors/packet-mongo.c @@ -291,7 +291,7 @@ dissect_bson_document(tvbuff_t *tvb, packet_info *pinfo, guint offset, proto_tre do { /* Read document elements */ - guint8 e_type = -1; /* Element type */ + guint8 e_type; /* Element type */ gint str_len = -1; /* String length */ gint e_len = -1; /* Element length */ gint doc_len = -1; /* Document length */ diff --git a/epan/dissectors/packet-openflow_v5.c b/epan/dissectors/packet-openflow_v5.c index 3e81d8e90a..410d95c82d 100644 --- a/epan/dissectors/packet-openflow_v5.c +++ b/epan/dissectors/packet-openflow_v5.c @@ -2513,7 +2513,6 @@ dissect_openflow_port_desc_prop_ethernet_v5(tvbuff_t *tvb, packet_info *pinfo _U offset+=4; return offset; - return offset; } |