aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-s7comm.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-06-26 10:52:37 -0400
committerPascal Quantin <pascal.quantin@gmail.com>2016-06-27 15:20:06 +0000
commit2ab415579491e4bc66ea58627bda504cae833b9e (patch)
tree0f7f8eaa4bd9d90c8f6066036522ef0fc65d137d /epan/dissectors/packet-s7comm.c
parent8c37621ca733a24a972e3e069a537c06e650f435 (diff)
tvb_get_string_enc + proto_tree_add_item = proto_tree_add_item_ret_string
Also some other tricks to remove unnecessary tvb_get_string_enc calls. Change-Id: I2f40d9175b6c0bb0b1364b4089bfaa287edf0914 Reviewed-on: https://code.wireshark.org/review/16158 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-s7comm.c')
-rw-r--r--epan/dissectors/packet-s7comm.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/epan/dissectors/packet-s7comm.c b/epan/dissectors/packet-s7comm.c
index 648a11ff97..fd7b2684a7 100644
--- a/epan/dissectors/packet-s7comm.c
+++ b/epan/dissectors/packet-s7comm.c
@@ -2748,7 +2748,7 @@ s7comm_decode_pistart_parameters(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree,
proto_tree *param_tree,
- gchar *servicename,
+ const guint8 *servicename,
guint8 nfields, /* number of fields used */
guint hf[12], /* array with header fields */
guint32 offset)
@@ -2794,9 +2794,9 @@ s7comm_decode_pi_service(tvbuff_t *tvb,
guint32 paramoffset;
guint8 count;
guint8 i;
- gchar *servicename;
- gchar *str;
- gchar *str1;
+ const guint8 *servicename;
+ const guint8 *str;
+ const guint8 *str1;
guint16 blocktype;
guint hf[13];
int pi_servicename_idx;
@@ -2833,8 +2833,7 @@ s7comm_decode_pi_service(tvbuff_t *tvb,
len = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_s7comm_piservice_string_len, tvb, offset, 1, len);
offset += 1;
- servicename = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII);
- item = proto_tree_add_item(tree, hf_s7comm_piservice_servicename, tvb, offset, len, ENC_ASCII|ENC_NA);
+ item = proto_tree_add_item_ret_string(tree, hf_s7comm_piservice_servicename, tvb, offset, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &servicename);
offset += len;
/* get the index position in pi_service_names, and add infotext with description to the item */
@@ -2863,8 +2862,7 @@ s7comm_decode_pi_service(tvbuff_t *tvb,
itemadd = proto_tree_add_item(file_tree, hf_s7comm_data_blockcontrol_block_type, tvb, paramoffset, 2, ENC_ASCII|ENC_NA);
proto_item_append_text(itemadd, " (%s)", val_to_str(blocktype, blocktype_names, "Unknown Block type: 0x%04x"));
paramoffset += 2;
- str = tvb_get_string_enc(wmem_packet_scope(), tvb, paramoffset, 5, ENC_ASCII);
- proto_tree_add_item(file_tree, hf_s7comm_data_blockcontrol_block_num, tvb, paramoffset, 5, ENC_ASCII|ENC_NA);
+ proto_tree_add_item_ret_string(file_tree, hf_s7comm_data_blockcontrol_block_num, tvb, paramoffset, 5, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str);
paramoffset += 5;
proto_item_append_text(file_tree, " [%s %d]",
val_to_str(blocktype, blocktype_names, "Unknown Block type: 0x%04x"),
@@ -2889,8 +2887,7 @@ s7comm_decode_pi_service(tvbuff_t *tvb,
proto_item_append_text(tree, " -> %s()", servicename);
col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s()", servicename);
} else {
- str1 = tvb_get_string_enc(wmem_packet_scope(), tvb, paramoffset, paramlen, ENC_ASCII);
- proto_tree_add_item(param_tree, hf_s7comm_data_plccontrol_argument, tvb, paramoffset, paramlen, ENC_ASCII|ENC_NA);
+ proto_tree_add_item_ret_string(param_tree, hf_s7comm_data_plccontrol_argument, tvb, paramoffset, paramlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str1);
proto_item_append_text(param_tree, ": (\"%s\")", str1);
proto_item_append_text(tree, " -> %s(\"%s\")", servicename, str1);
col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s(\"%s\")", servicename, str1);
@@ -3190,7 +3187,7 @@ s7comm_decode_plc_controls_filename(tvbuff_t *tvb,
guint32 offset)
{
guint8 len;
- guint8 *str;
+ const guint8 *str;
guint16 blocktype;
gboolean is_plcfilename;
proto_item *item = NULL;
@@ -3217,8 +3214,7 @@ s7comm_decode_plc_controls_filename(tvbuff_t *tvb,
itemadd = proto_tree_add_item(file_tree, hf_s7comm_data_blockcontrol_block_type, tvb, offset, 2, ENC_ASCII|ENC_NA);
proto_item_append_text(itemadd, " (%s)", val_to_str(blocktype, blocktype_names, "Unknown Block type: 0x%04x"));
offset += 2;
- str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 5, ENC_ASCII);
- proto_tree_add_item(file_tree, hf_s7comm_data_blockcontrol_block_num, tvb, offset, 5, ENC_ASCII|ENC_NA);
+ proto_tree_add_item_ret_string(file_tree, hf_s7comm_data_blockcontrol_block_num, tvb, offset, 5, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str);
offset += 5;
proto_item_append_text(file_tree, " [%s %d]",
val_to_str(blocktype, blocktype_names, "Unknown Block type: 0x%04x"),
@@ -4284,7 +4280,7 @@ s7comm_decode_ud_block_subfunc(tvbuff_t *tvb,
{
guint16 count;
guint16 i;
- guint8 *pBlocknumber;
+ const guint8 *pBlocknumber;
guint16 blocknumber;
guint8 blocktype;
guint16 blocktype16;
@@ -4370,8 +4366,7 @@ s7comm_decode_ud_block_subfunc(tvbuff_t *tvb,
itemadd = proto_tree_add_item(data_tree, hf_s7comm_ud_blockinfo_block_type, tvb, offset, 2, ENC_ASCII|ENC_NA);
proto_item_append_text(itemadd, " (%s)", val_to_str(blocktype16, blocktype_names, "Unknown Block type: 0x%04x"));
offset += 2;
- proto_tree_add_item(data_tree, hf_s7comm_ud_blockinfo_block_num_ascii, tvb, offset, 5, ENC_ASCII|ENC_NA);
- pBlocknumber = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 5, ENC_ASCII);
+ proto_tree_add_item_ret_string(data_tree, hf_s7comm_ud_blockinfo_block_num_ascii, tvb, offset, 5, ENC_ASCII|ENC_NA, wmem_packet_scope(), &pBlocknumber);
proto_item_append_text(data_tree, " [%s %d]",
val_to_str(blocktype16, blocktype_names, "Unknown Block type: 0x%04x"),
atoi(pBlocknumber));