Create temporary variables for some proto_tree_add_<datatype> calculations.

checkAPIs.pl doesn't like tvb_get_* parameters because it thinks
proto_tree_add_item should be used.  This is just to pacify the check.

Change-Id: If40728bcdf5558c351999057321ffba5d802c7c7
Reviewed-on: https://code.wireshark.org/review/21694
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Michael Mann 2017-05-16 22:55:34 -04:00 committed by Anders Broman
parent 99b76a5bc3
commit 8376a8bb26
10 changed files with 56 additions and 41 deletions

View File

@ -4228,6 +4228,7 @@ spotlight_dissect_query_loop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
guint byte_order;
gboolean mark_exists;
tvbuff_t *spotlight_tvb;
guint8 *str_tmp;
proto_item *item_query;
proto_tree *sub_tree;
@ -4367,8 +4368,8 @@ spotlight_dissect_query_loop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
case SQ_TYPE_DATA:
switch (cpx_query_type) {
case SQ_CPX_TYPE_STRING:
proto_tree_add_string(tree, hf_afp_string, tvb, offset, query_length,
tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 8, query_length - 8, ENC_UTF_8|ENC_NA));
str_tmp = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 8, query_length - 8, ENC_UTF_8|ENC_NA);
proto_tree_add_string(tree, hf_afp_string, tvb, offset, query_length, str_tmp);
break;
case SQ_CPX_TYPE_UTF16_STRING: {
/* description see above */
@ -4379,9 +4380,9 @@ spotlight_dissect_query_loop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
} else
mark_exists = TRUE;
proto_tree_add_string(tree, hf_afp_utf_16_string, tvb, offset, query_length,
tvb_get_string_enc(wmem_packet_scope(), tvb, offset + (mark_exists ? 10 : 8),
query_length - (mark_exists? 10 : 8), ENC_UTF_16 | byte_order));
str_tmp = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + (mark_exists ? 10 : 8),
query_length - (mark_exists? 10 : 8), ENC_UTF_16 | byte_order);
proto_tree_add_string(tree, hf_afp_utf_16_string, tvb, offset, query_length, str_tmp);
break;
}
case SQ_CPX_TYPE_FILEMETA:

View File

@ -117,6 +117,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
proto_item *ti, *sub_item;
proto_tree *ar_tree, *sub_tree;
char *command;
guint8 *complete_str;
guint32 dword;
if (tvb_captured_length(tvb) < 4)
@ -144,8 +145,8 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
return master_offset;
command = tvb_get_string_enc(wmem_packet_scope(), tvb, master_offset, offset-master_offset, ENC_ASCII|ENC_NA);
sub_item = proto_tree_add_string(ar_tree, hf_command, tvb, master_offset, -1,
tvb_get_string_enc(wmem_packet_scope(), tvb, master_offset+3, offset-master_offset-3, ENC_ASCII|ENC_NA));
complete_str = tvb_get_string_enc(wmem_packet_scope(), tvb, master_offset+3, offset-master_offset-3, ENC_ASCII|ENC_NA);
sub_item = proto_tree_add_string(ar_tree, hf_command, tvb, master_offset, -1, complete_str);
if (!strncmp(command, "AT*PCMD", 7))
{

View File

@ -217,7 +217,8 @@ dissect_classicstun(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d
guint16 msg_length;
const char *msg_type_str;
guint16 att_type;
guint16 att_length;
guint16 att_length, clear_port;
guint32 clear_ip;
guint16 offset;
guint len;
guint i;
@ -491,9 +492,8 @@ dissect_classicstun(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d
/* Show the port 'in the clear'
XOR (host order) transid with (host order) xor-port.
Add host-order port into tree. */
ti = proto_tree_add_uint(att_tree, classicstun_att_port, tvb, offset+2, 2,
tvb_get_ntohs(tvb, offset+2) ^
(transaction_id_first_word >> 16));
clear_port = tvb_get_ntohs(tvb, offset+2) ^ (transaction_id_first_word >> 16);
ti = proto_tree_add_uint(att_tree, classicstun_att_port, tvb, offset+2, 2, clear_port);
PROTO_ITEM_SET_GENERATED(ti);
switch( tvb_get_guint8(tvb, offset+1) ){
@ -505,8 +505,8 @@ dissect_classicstun(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d
/* Show the address 'in the clear'.
XOR (host order) transid with (host order) xor-address.
Add in network order tree. */
ti = proto_tree_add_ipv4(att_tree, classicstun_att_ipv4, tvb, offset+4, 4,
tvb_get_ipv4(tvb, offset+4) ^ g_htonl(transaction_id_first_word));
clear_ip = tvb_get_ipv4(tvb, offset+4) ^ g_htonl(transaction_id_first_word);
ti = proto_tree_add_ipv4(att_tree, classicstun_att_ipv4, tvb, offset+4, 4, clear_ip);
PROTO_ITEM_SET_GENERATED(ti);
break;

View File

@ -18883,6 +18883,7 @@ dissect_ieee80211_common(tvbuff_t *tvb, packet_info *pinfo,
tvbuff_t *volatile msdu_tvb;
guint16 msdu_length;
proto_tree *subframe_tree;
const gchar *resolve_name;
/*
* IEEE Std 802.11-2012 says, in section 8.3.2.2 "A-MSDU format":
@ -18903,12 +18904,14 @@ dissect_ieee80211_common(tvbuff_t *tvb, packet_info *pinfo,
i += 1;
proto_tree_add_item(subframe_tree, hf_ieee80211_addr_da, next_tvb, msdu_offset, 6, ENC_NA);
resolve_name = tvb_get_ether_name(tvb, msdu_offset);
hidden_item = proto_tree_add_string(hdr_tree, hf_ieee80211_addr_da_resolved, tvb, msdu_offset, 6,
tvb_get_ether_name(tvb, msdu_offset));
resolve_name);
PROTO_ITEM_SET_HIDDEN(hidden_item);
proto_tree_add_item(subframe_tree, hf_ieee80211_addr_sa, next_tvb, msdu_offset+6, 6, ENC_NA);
resolve_name = tvb_get_ether_name(tvb, msdu_offset+6);
hidden_item = proto_tree_add_string(hdr_tree, hf_ieee80211_addr_sa_resolved, tvb, msdu_offset+6, 6,
tvb_get_ether_name(tvb, msdu_offset+6));
resolve_name);
PROTO_ITEM_SET_HIDDEN(hidden_item);
proto_tree_add_item(subframe_tree, hf_ieee80211_amsdu_length, next_tvb, msdu_offset+12, 2, ENC_BIG_ENDIAN);

View File

@ -152,6 +152,7 @@ int lct_ext_decode(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, guint of
start_offset = offset;
proto_item *ti;
proto_tree *hec_tree, *ext_tree;
double cc_loss;
/* Figure out the extention count */
while (tmp_offset < offset_max)
@ -213,7 +214,8 @@ int lct_ext_decode(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, guint of
proto_tree_add_item(ext_tree, hf_cc_sequence, tvb, offset+2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(ext_tree, hf_cc_flags, tvb, offset+4, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ext_tree, hf_cc_rtt, tvb, offset+5, 1, ENC_BIG_ENDIAN);
proto_tree_add_double(ext_tree, hf_cc_loss, tvb, offset+6, 2, tvb_get_ntohs(tvb, offset+6)/65535.0);
cc_loss = tvb_get_ntohs(tvb, offset+6)/65535.0;
proto_tree_add_double(ext_tree, hf_cc_loss, tvb, offset+6, 2, cc_loss);
proto_tree_add_item(ext_tree, hf_cc_rate, tvb, offset+8, 2, ENC_BIG_ENDIAN);
break;

View File

@ -4000,10 +4000,13 @@ dissect_scsi_spc_modepage(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree *tree, guint offset, guint8 pcode, guint8 spf, guint8 subpcode)
{
guint8 flags, proto;
guint32 burst_size, condition_timer;
switch (pcode) {
case SCSI_SPC_MODEPAGE_CTL:
if (!spf) {
guint32 timeout_period;
/* standard page for control */
proto_tree_add_item(tree, hf_scsi_modesns_tst, tvb, offset+2, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_spc_modepage_gltsd, tvb, offset+2, 1, ENC_BIG_ENDIAN);
@ -4016,8 +4019,8 @@ dissect_scsi_spc_modepage(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree_add_item(tree, hf_scsi_spc_modepage_swp, tvb, offset+4, 1, ENC_NA);
proto_tree_add_item(tree, hf_scsi_spc_modepage_autoload_mode, tvb, offset+5, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_spc_modepage_ready_aer_holdoff_period, tvb, offset+6, 2, ENC_BIG_ENDIAN);
proto_tree_add_uint(tree, hf_scsi_spc_modepage_busy_timeout_period, tvb, offset+8, 2,
tvb_get_ntohs(tvb, offset+8)*100);
timeout_period = tvb_get_ntohs(tvb, offset+8)*100;
proto_tree_add_uint(tree, hf_scsi_spc_modepage_busy_timeout_period, tvb, offset+8, 2, timeout_period);
proto_tree_add_item(tree, hf_scsi_spc_modepage_extended_self_test_completion_time, tvb, offset+10, 2, ENC_BIG_ENDIAN);
} else {
switch (subpcode) {
@ -4046,14 +4049,14 @@ dissect_scsi_spc_modepage(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree_add_item(tree, hf_scsi_spc_modepage_bus_inactivity_limit, tvb, offset+4, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_spc_modepage_disconnect_time_limit, tvb, offset+6, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_spc_modepage_connect_time_limit, tvb, offset+8, 2, ENC_BIG_ENDIAN);
proto_tree_add_uint(tree, hf_scsi_spc_modepage_maximum_burst_size, tvb, offset+10, 2,
tvb_get_ntohs(tvb, offset+10)*512);
burst_size = tvb_get_ntohs(tvb, offset+10)*512;
proto_tree_add_uint(tree, hf_scsi_spc_modepage_maximum_burst_size, tvb, offset+10, 2, burst_size);
proto_tree_add_item(tree, hf_scsi_spc_modepage_emdp, tvb, offset+12, 1, ENC_NA);
proto_tree_add_item(tree, hf_scsi_spc_modepage_faa, tvb, offset+12, 1, ENC_NA);
proto_tree_add_item(tree, hf_scsi_spc_modepage_fab, tvb, offset+12, 1, ENC_NA);
proto_tree_add_item(tree, hf_scsi_spc_modepage_fac, tvb, offset+12, 1, ENC_NA);
proto_tree_add_uint(tree, hf_scsi_spc_modepage_first_burst_size, tvb, offset+14, 2,
tvb_get_ntohs(tvb, offset+14)*512);
burst_size = tvb_get_ntohs(tvb, offset+14)*512;
proto_tree_add_uint(tree, hf_scsi_spc_modepage_first_burst_size, tvb, offset+14, 2, burst_size);
break;
case SCSI_SPC_MODEPAGE_INFOEXCP:
flags = tvb_get_guint8(tvb, offset+2);
@ -4078,10 +4081,10 @@ dissect_scsi_spc_modepage(tvbuff_t *tvb, packet_info *pinfo _U_,
case SCSI_SPC_MODEPAGE_PWR:
proto_tree_add_item(tree, hf_scsi_spc_modepage_idle, tvb, offset+3, 1, ENC_NA);
proto_tree_add_item(tree, hf_scsi_spc_modepage_standby, tvb, offset+3, 1, ENC_NA);
proto_tree_add_uint(tree, hf_scsi_spc_modepage_idle_condition_timer, tvb, offset+4, 2,
tvb_get_ntohs(tvb, offset+4) * 100);
proto_tree_add_uint(tree, hf_scsi_spc_modepage_standby_condition_timer, tvb, offset+6, 2,
tvb_get_ntohs(tvb, offset+6) * 100);
condition_timer = tvb_get_ntohs(tvb, offset+4) * 100;
proto_tree_add_uint(tree, hf_scsi_spc_modepage_idle_condition_timer, tvb, offset+4, 2, condition_timer);
condition_timer = tvb_get_ntohs(tvb, offset+6) * 100;
proto_tree_add_uint(tree, hf_scsi_spc_modepage_standby_condition_timer, tvb, offset+6, 2, condition_timer);
break;
case SCSI_SPC_MODEPAGE_LUN:
return FALSE;

View File

@ -793,8 +793,8 @@ static const item_t lm_params_resp_netshareenum[] = {
static proto_item *
netshareenum_share_entry(tvbuff_t *tvb, proto_tree *tree, int offset)
{
return proto_tree_add_string(tree, hf_share, tvb, offset, -1,
tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 13, ENC_ASCII));
guint8 * share_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 13, ENC_ASCII);
return proto_tree_add_string(tree, hf_share, tvb, offset, -1, share_str);
}
static const item_t lm_null[] = {
@ -990,8 +990,8 @@ static const item_t lm_params_req_netserverenum2[] = {
static proto_item *
netserverenum2_server_entry(tvbuff_t *tvb, proto_tree *tree, int offset)
{
return proto_tree_add_string(tree, hf_server, tvb, offset, -1,
tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 16, ENC_ASCII));
guint8 * server_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 16, ENC_ASCII);
return proto_tree_add_string(tree, hf_server, tvb, offset, -1, server_str);
}
static const item_t lm_params_resp_netserverenum2[] = {

View File

@ -2797,7 +2797,7 @@ static void
dissect_pct_msg_client_hello(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, guint32 offset)
{
guint16 CH_CLIENT_VERSION, CH_OFFSET, CH_CIPHER_SPECS_LENGTH, CH_HASH_SPECS_LENGTH, CH_CERT_SPECS_LENGTH, CH_EXCH_SPECS_LENGTH, CH_KEY_ARG_LENGTH;
guint16 CH_CLIENT_VERSION, CH_OFFSET, CH_CIPHER_SPECS_LENGTH, CH_HASH_SPECS_LENGTH, CH_CERT_SPECS_LENGTH, CH_EXCH_SPECS_LENGTH, CH_KEY_ARG_LENGTH, mac_key_length;
proto_item *CH_CIPHER_SPECS_ti, *CH_HASH_SPECS_ti, *CH_CERT_SPECS_ti, *CH_EXCH_SPECS_ti, *ti;
proto_tree *CH_CIPHER_SPECS_tree, *CH_HASH_SPECS_tree, *CH_CERT_SPECS_tree, *CH_EXCH_SPECS_tree;
gint i;
@ -2852,7 +2852,8 @@ dissect_pct_msg_client_hello(tvbuff_t *tvb, packet_info *pinfo,
offset += 2;
proto_tree_add_item(CH_CIPHER_SPECS_tree, hf_ssl_pct_encryption_key_length, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_uint(CH_CIPHER_SPECS_tree, hf_ssl_pct_mac_key_length_in_bits, tvb, offset, 1, tvb_get_guint8(tvb, offset) + 64);
mac_key_length = tvb_get_guint8(tvb, offset) + 64;
proto_tree_add_uint(CH_CIPHER_SPECS_tree, hf_ssl_pct_mac_key_length_in_bits, tvb, offset, 1, mac_key_length);
offset += 1;
}
}
@ -2922,7 +2923,7 @@ dissect_pct_msg_server_hello(tvbuff_t *tvb, proto_tree *tree, guint32 offset, pa
*/
guint16 SH_SERVER_VERSION, SH_CERT_LENGTH, SH_CERT_SPECS_LENGTH, SH_CLIENT_SIG_LENGTH, SH_RESPONSE_LENGTH;
guint16 SH_SERVER_VERSION, SH_CERT_LENGTH, SH_CERT_SPECS_LENGTH, SH_CLIENT_SIG_LENGTH, SH_RESPONSE_LENGTH, mac_key_length;
proto_item* ti;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
@ -2946,7 +2947,8 @@ dissect_pct_msg_server_hello(tvbuff_t *tvb, proto_tree *tree, guint32 offset, pa
offset += 2;
proto_tree_add_item(tree, hf_ssl_pct_encryption_key_length, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_uint(tree, hf_ssl_pct_mac_key_length_in_bits, tvb, offset, 1, tvb_get_guint8(tvb, offset) + 64);
mac_key_length = tvb_get_guint8(tvb, offset) + 64;
proto_tree_add_uint(tree, hf_ssl_pct_mac_key_length_in_bits, tvb, offset, 1, mac_key_length);
offset += 1;
proto_tree_add_item(tree, hf_pct_handshake_hash, tvb, offset, 2, ENC_BIG_ENDIAN);

View File

@ -547,7 +547,8 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
const char *msg_class_str;
const char *msg_method_str;
guint16 att_type;
guint16 att_length;
guint16 att_length, clear_port;
guint32 clear_ip;
guint i;
guint offset;
guint magic_cookie_first_word;
@ -1048,8 +1049,8 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
/* Show the port 'in the clear'
XOR (host order) transid with (host order) xor-port.
Add host-order port into tree. */
ti = proto_tree_add_uint(att_tree, hf_stun_att_port, tvb, offset+2, 2,
tvb_get_ntohs(tvb, offset+2) ^ (magic_cookie_first_word >> 16));
clear_port = tvb_get_ntohs(tvb, offset+2) ^ (magic_cookie_first_word >> 16);
ti = proto_tree_add_uint(att_tree, hf_stun_att_port, tvb, offset+2, 2, clear_port);
PROTO_ITEM_SET_GENERATED(ti);
if (att_length < 8)
@ -1061,8 +1062,8 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
/* Show the address 'in the clear'.
XOR (host order) transid with (host order) xor-address.
Add in network order tree. */
ti = proto_tree_add_ipv4(att_tree, hf_stun_att_ipv4, tvb, offset+4, 4,
tvb_get_ipv4(tvb, offset+4) ^ g_htonl(magic_cookie_first_word));
clear_ip = tvb_get_ipv4(tvb, offset+4) ^ g_htonl(magic_cookie_first_word);
ti = proto_tree_add_ipv4(att_tree, hf_stun_att_ipv4, tvb, offset+4, 4, clear_ip);
PROTO_ITEM_SET_GENERATED(ti);
{

View File

@ -2084,6 +2084,8 @@ dissect_cpch_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
else {
guint cfn;
guint header_length = 0;
guint32 propagation_delay = 0;
/* DATA */
/* CFN */
@ -2098,8 +2100,8 @@ dissect_cpch_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
offset++;
/* Propagation delay */
proto_tree_add_uint(tree, hf_fp_propagation_delay, tvb, offset, 1,
tvb_get_guint8(tvb, offset) * 3);
propagation_delay = tvb_get_guint8(tvb, offset) *3;
proto_tree_add_uint(tree, hf_fp_propagation_delay, tvb, offset, 1, propagation_delay);
offset++;
header_length = offset; /* XXX this might be wrong */
/* TB data */