diff options
author | Alexandr Savca <s.alex08@mail.ru> | 2018-04-19 18:48:19 +0300 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2018-04-19 17:31:49 +0000 |
commit | b545c60658143a730619df7b6c6f6df2f22e6398 (patch) | |
tree | b14c5755c468494df409a5700fe33b41980e2b86 | |
parent | 04aedf3682f3b65f2eeef2cfb0230354f420c696 (diff) |
Fix cppcheck 1.83 warnings
[packet-ber.c:2687]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[packet-erf.c:2475]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[packet-fmp.c:378]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[packet-http2.c:2050]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[packet-obd-ii.c:643]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[packet-yami.c:244]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
Change-Id: Ie71f9f7c8f863d1e9c693bd56444f00bdad48042
Reviewed-on: https://code.wireshark.org/review/27019
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
-rw-r--r-- | epan/dissectors/packet-ber.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-erf.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-fmp.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-http2.c | 12 | ||||
-rw-r--r-- | epan/dissectors/packet-obd-ii.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-yami.c | 2 |
6 files changed, 11 insertions, 11 deletions
diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c index 9fb27749bb..9f7d358510 100644 --- a/epan/dissectors/packet-ber.c +++ b/epan/dissectors/packet-ber.c @@ -2684,7 +2684,7 @@ proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) calling subdissector\n" /* OK - we didn't find some of the elements we expected */ for (set_idx = 0; (cset = &set[set_idx])->func && (set_idx < MAX_SET_ELEMENTS); set_idx++) { - if (mandatory_fields & (1 << set_idx)) { + if (mandatory_fields & (1U << set_idx)) { /* here is something we should have seen - but didn't! */ cause = proto_tree_add_string_format_value( tree, hf_ber_error, tvb, offset, lenx, "missing_field", diff --git a/epan/dissectors/packet-erf.c b/epan/dissectors/packet-erf.c index b491303d30..cc3a7193ba 100644 --- a/epan/dissectors/packet-erf.c +++ b/epan/dissectors/packet-erf.c @@ -2472,7 +2472,7 @@ dissect_meta_tag_ext_hdrs(proto_item *section_tree, tvbuff_t *tvb, int offset, g /* Add all set bits to the header, including the ones we don't understand */ for (bit_offset = 0; bit_offset < 32; bit_offset++) { - if (ext_hdrs[int_offset] & (1 << bit_offset)) { + if (ext_hdrs[int_offset] & (1U << bit_offset)) { proto_item_append_text(subtree_pi, ", %s", val_to_str(ext_hdr_num, ehdr_type_vals, "%d")); /* Also add to the top level */ diff --git a/epan/dissectors/packet-fmp.c b/epan/dissectors/packet-fmp.c index f336bcfec0..fa887bc46b 100644 --- a/epan/dissectors/packet-fmp.c +++ b/epan/dissectors/packet-fmp.c @@ -375,7 +375,7 @@ dissect_fmp_flushCmd(tvbuff_t *tvb, int offset, proto_tree *tree) for (i = 0; cmd != 0 && i < 32; i++) { - bitValue = 1 << i; + bitValue = 1U << i; if (cmd & bitValue) { switch (bitValue) { diff --git a/epan/dissectors/packet-http2.c b/epan/dissectors/packet-http2.c index 6ca87516b7..d0ffdc39b4 100644 --- a/epan/dissectors/packet-http2.c +++ b/epan/dissectors/packet-http2.c @@ -1105,7 +1105,7 @@ get_http2_session(packet_info *pinfo) } #ifdef HAVE_NGHTTP2 -static int +static guint32 select_http2_flow_index(packet_info *pinfo, http2_session_t *h2session) { struct tcp_analysis *tcpd; @@ -1147,7 +1147,7 @@ get_oneway_stream_info(packet_info *pinfo, gboolean the_other_direction) { http2_session_t *http2_session = get_http2_session(pinfo); http2_stream_info_t *http2_stream_info = get_stream_info(http2_session); - int flow_index = select_http2_flow_index(pinfo, http2_session); + guint32 flow_index = select_http2_flow_index(pinfo, http2_session); if (the_other_direction) { /* need stream info of the other direction, so set index from 0 to 1, or from 1 to 0 */ @@ -1181,7 +1181,7 @@ push_settings(packet_info *pinfo, http2_session_t *h2session, http2_settings_t *settings) { wmem_queue_t *queue; - int flow_index; + guint32 flow_index; flow_index = select_http2_flow_index(pinfo, h2session); @@ -1196,7 +1196,7 @@ apply_and_pop_settings(packet_info *pinfo, http2_session_t *h2session) wmem_queue_t *queue; http2_settings_t *settings; nghttp2_hd_inflater *inflater; - int flow_index; + guint32 flow_index; /* When header table size is applied, it affects the inflater of opposite side. */ @@ -1566,7 +1566,7 @@ inflate_http2_header_block(tvbuff_t *tvb, packet_info *pinfo, guint offset, int rv; int header_len = 0; int final; - int flow_index; + guint32 flow_index; http2_header_data_t *header_data; http2_header_repr_info_t *header_repr_info; wmem_list_t *header_list; @@ -2043,7 +2043,7 @@ get_reassembly_id_from_stream(packet_info *pinfo) { http2_session_t *session = get_http2_session(pinfo); http2_stream_info_t *stream_info = get_stream_info(session); - int flow_index = select_http2_flow_index(pinfo, session); + guint32 flow_index = select_http2_flow_index(pinfo, session); /* With a stream ID being 31 bits, use the most significant bit to determine the flow direction of the * stream. We use this for the ID in the body reassembly using the reassemble API */ diff --git a/epan/dissectors/packet-obd-ii.c b/epan/dissectors/packet-obd-ii.c index 66d00a4063..f04515ed15 100644 --- a/epan/dissectors/packet-obd-ii.c +++ b/epan/dissectors/packet-obd-ii.c @@ -640,7 +640,7 @@ dissect_obdii_mode_01(tvbuff_t *tvb, struct obdii_packet_info *oinfo, proto_tree memset(bits_str, '.', 32); bits_str[32] = '\0'; - if ((val & (1 << i))) + if ((val & (1U << i))) { col_append_fstr(oinfo->pinfo->cinfo, COL_INFO, "%s%.2X", sepa, this_pid); ti = proto_tree_add_uint(tree, hf_obdii_mode01_supported_pid, tvb, value_offset, oinfo->value_bytes, this_pid); diff --git a/epan/dissectors/packet-yami.c b/epan/dissectors/packet-yami.c index 88b5cfc411..d99409a665 100644 --- a/epan/dissectors/packet-yami.c +++ b/epan/dissectors/packet-yami.c @@ -241,7 +241,7 @@ dissect_yami_parameter(tvbuff_t *tvb, proto_tree *tree, int offset, proto_item * guint32 val = tvb_get_letohl(tvb, offset); for (j = 0; j < 32; j++) { - int r = !!(val & (1 << j)); + int r = !!(val & (1U << j)); proto_item_append_text(ti, "%s, ", r ? "T" : "F"); proto_tree_add_boolean(yami_param, &hfi_yami_param_value_bool, tvb, offset+(j/8), 1, r); |