aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorMartin Mathieson <martin.r.mathieson@googlemail.com>2012-09-19 11:58:32 +0000
committerMartin Mathieson <martin.r.mathieson@googlemail.com>2012-09-19 11:58:32 +0000
commita232ae9242177783bc260311b160d5110e809883 (patch)
tree0c26847da94d9030a74a19875139699f72eb7ea8 /epan
parent0543f20a15aa5fa46f94227b1dfbca5f84dda5e9 (diff)
Make proto_item_append_string() behave sanely, and use it in a few more
dissectors. svn path=/trunk/; revision=45005
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-mac-lte.c34
-rw-r--r--epan/dissectors/packet-pdcp-lte.c6
-rw-r--r--epan/dissectors/packet-rlc-lte.c10
-rw-r--r--epan/dissectors/packet-wsp.c11
-rw-r--r--epan/proto.c50
5 files changed, 48 insertions, 63 deletions
diff --git a/epan/dissectors/packet-mac-lte.c b/epan/dissectors/packet-mac-lte.c
index 0424695a87..051ec1c925 100644
--- a/epan/dissectors/packet-mac-lte.c
+++ b/epan/dissectors/packet-mac-lte.c
@@ -1308,10 +1308,10 @@ static void write_pdu_label_and_info(proto_item *ti1, proto_item *ti2,
col_append_str(pinfo->cinfo, COL_INFO, info_buffer);
}
if (ti1 != NULL) {
- proto_item_append_text(ti1, "%s", info_buffer);
+ proto_item_append_string(ti1, info_buffer);
}
if (ti2 != NULL) {
- proto_item_append_text(ti2, "%s", info_buffer);
+ proto_item_append_string(ti2, info_buffer);
}
}
@@ -1369,7 +1369,7 @@ static void show_extra_phy_parameters(packet_info *pinfo, tvbuff_t *tvb, proto_t
PROTO_ITEM_SET_GENERATED(ti);
- proto_item_append_text(phy_ti, " (");
+ proto_item_append_string(phy_ti, " (");
write_pdu_label_and_info(phy_ti, NULL,
(global_mac_lte_layer_to_show == ShowPHYLayer) ? pinfo : NULL,
@@ -1382,7 +1382,7 @@ static void show_extra_phy_parameters(packet_info *pinfo, tvbuff_t *tvb, proto_t
p_mac_lte_info->detailed_phy_info.ul_info.resource_block_length,
p_mac_lte_info->detailed_phy_info.ul_info.resource_block_start);
- proto_item_append_text(phy_ti, ")");
+ proto_item_append_string(phy_ti, ")");
/* Don't want columns to be replaced now */
if (global_mac_lte_layer_to_show == ShowPHYLayer) {
@@ -1456,7 +1456,7 @@ static void show_extra_phy_parameters(packet_info *pinfo, tvbuff_t *tvb, proto_t
PROTO_ITEM_SET_GENERATED(ti);
- proto_item_append_text(phy_ti, " (");
+ proto_item_append_string(phy_ti, " (");
write_pdu_label_and_info(phy_ti, NULL,
(global_mac_lte_layer_to_show == ShowPHYLayer) ? pinfo : NULL,
@@ -1476,7 +1476,7 @@ static void show_extra_phy_parameters(packet_info *pinfo, tvbuff_t *tvb, proto_t
crc_status_vals, "Unknown"),
p_mac_lte_info->detailed_phy_info.dl_info.harq_id,
p_mac_lte_info->detailed_phy_info.dl_info.ndi);
- proto_item_append_text(phy_ti, ")");
+ proto_item_append_string(phy_ti, ")");
/* Don't want columns to be replaced now */
if (global_mac_lte_layer_to_show == ShowPHYLayer) {
@@ -1694,7 +1694,7 @@ static void dissect_rar(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
val_to_str_const(backoff_indicator, rar_bi_vals, "Illegal-value "));
}
else {
- proto_item_append_text(rar_headers_ti, ")");
+ proto_item_append_string(rar_headers_ti, ")");
}
/* Set length for headers root */
@@ -2876,14 +2876,14 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
switch (pdu_lengths[number_of_headers]) {
case -1:
- proto_item_append_text(pdu_subheader_ti, ", length is remainder)");
+ proto_item_append_string(pdu_subheader_ti, ", length is remainder)");
proto_item_append_text(pdu_header_ti, " (%s:remainder)",
val_to_str_const(lcids[number_of_headers],
(direction == DIRECTION_UPLINK) ? ulsch_lcid_vals : dlsch_lcid_vals,
"Unknown"));
break;
case 0:
- proto_item_append_text(pdu_subheader_ti, ")");
+ proto_item_append_string(pdu_subheader_ti, ")");
proto_item_append_text(pdu_header_ti, " (%s)",
val_to_str_const(lcids[number_of_headers],
(direction == DIRECTION_UPLINK) ? ulsch_lcid_vals : dlsch_lcid_vals,
@@ -3058,7 +3058,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
/* Now show CR result in tree */
switch (crResult->status) {
case NoMsg3:
- proto_item_append_text(cr_ti, " (no corresponding Msg3 found!)");
+ proto_item_append_string(cr_ti, " (no corresponding Msg3 found!)");
break;
case Msg3Match:
@@ -3664,7 +3664,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
break;
}
}
- proto_item_append_text(sdu_ti, "%s", buff);
+ proto_item_append_string(sdu_ti, buff);
}
offset += data_length;
@@ -3907,14 +3907,14 @@ static void dissect_mch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
switch (pdu_lengths[number_of_headers]) {
case -1:
- proto_item_append_text(pdu_subheader_ti, ", length is remainder)");
+ proto_item_append_string(pdu_subheader_ti, ", length is remainder)");
proto_item_append_text(pdu_header_ti, " (%s:remainder)",
val_to_str_const(lcids[number_of_headers],
mch_lcid_vals,
"Unknown"));
break;
case 0:
- proto_item_append_text(pdu_subheader_ti, ")");
+ proto_item_append_string(pdu_subheader_ti, ")");
proto_item_append_text(pdu_header_ti, " (%s)",
val_to_str_const(lcids[number_of_headers],
mch_lcid_vals,
@@ -4010,10 +4010,10 @@ static void dissect_mch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
ti = proto_tree_add_item(mch_sched_info_tree, hf_mac_lte_control_mch_scheduling_info_stop_mtch,
tvb, curr_offset, 2, ENC_BIG_ENDIAN);
if ((stop_mtch_val >= 2043) && (stop_mtch_val <= 2046)) {
- proto_item_append_text(ti, " (reserved)");
+ proto_item_append_string(ti, " (reserved)");
}
else if (stop_mtch_val == 2047) {
- proto_item_append_text(ti, " (MTCH is not scheduled)");
+ proto_item_append_string(ti, " (MTCH is not scheduled)");
}
curr_offset += 2;
}
@@ -4079,7 +4079,7 @@ static void dissect_mch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
break;
}
}
- proto_item_append_text(sdu_ti, "%s", buff);
+ proto_item_append_string(sdu_ti, buff);
offset += data_length;
}
@@ -4143,7 +4143,7 @@ void dissect_mac_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* Create protocol tree. */
pdu_ti = proto_tree_add_item(tree, proto_mac_lte, tvb, offset, -1, ENC_NA);
- proto_item_append_text(pdu_ti, " ");
+ proto_item_append_string(pdu_ti, " ");
mac_lte_tree = proto_item_add_subtree(pdu_ti, ett_mac_lte);
diff --git a/epan/dissectors/packet-pdcp-lte.c b/epan/dissectors/packet-pdcp-lte.c
index 18610b1f90..76295695a1 100644
--- a/epan/dissectors/packet-pdcp-lte.c
+++ b/epan/dissectors/packet-pdcp-lte.c
@@ -401,7 +401,7 @@ static void addChannelSequenceInfo(pdcp_sequence_report_in_frame *p,
ti = proto_tree_add_boolean(seqnum_tree, hf_pdcp_lte_sequence_analysis_ok,
tvb, 0, 0, TRUE);
PROTO_ITEM_SET_GENERATED(ti);
- proto_item_append_text(seqnum_ti, " - OK");
+ proto_item_append_string(seqnum_ti, " - OK");
/* Link to next SN in channel (if known) */
if (p->nextFrameNum != 0) {
@@ -632,7 +632,7 @@ static void write_pdu_label_and_info(proto_item *pdu_ti,
/* Add to indicated places */
col_append_str(pinfo->cinfo, COL_INFO, info_buffer);
- proto_item_append_text(pdu_ti, "%s", info_buffer);
+ proto_item_append_string(pdu_ti, info_buffer);
}
@@ -748,7 +748,7 @@ static void show_pdcp_config(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree
mode[0],
val_to_str_const(p_pdcp_info->profile, rohc_profile_vals, "Unknown"));
}
- proto_item_append_text(configuration_ti, ")");
+ proto_item_append_string(configuration_ti, ")");
PROTO_ITEM_SET_GENERATED(configuration_ti);
/* Show plane in info column */
diff --git a/epan/dissectors/packet-rlc-lte.c b/epan/dissectors/packet-rlc-lte.c
index 55c2e6fbea..95a0a222f3 100644
--- a/epan/dissectors/packet-rlc-lte.c
+++ b/epan/dissectors/packet-rlc-lte.c
@@ -613,9 +613,9 @@ static void write_pdu_label_and_info(proto_item *pdu_ti, proto_item *sub_ti,
/* Add to indicated places */
col_append_str(pinfo->cinfo, COL_INFO, info_buffer);
- proto_item_append_text(pdu_ti, "%s", info_buffer);
+ proto_item_append_string(pdu_ti, info_buffer);
if (sub_ti != NULL) {
- proto_item_append_text(sub_ti, "%s", info_buffer);
+ proto_item_append_string(sub_ti, info_buffer);
}
}
@@ -931,7 +931,7 @@ static void addChannelSequenceInfo(sequence_analysis_report *p,
ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok,
tvb, 0, 0, TRUE);
PROTO_ITEM_SET_GENERATED(ti);
- proto_item_append_text(seqnum_ti, " - OK");
+ proto_item_append_string(seqnum_ti, " - OK");
/* Link to next SN in channel (if known) */
if (p->nextFrameNum != 0) {
@@ -1152,7 +1152,7 @@ static void addChannelSequenceInfo(sequence_analysis_report *p,
ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok,
tvb, 0, 0, TRUE);
PROTO_ITEM_SET_GENERATED(ti);
- proto_item_append_text(seqnum_ti, " - OK");
+ proto_item_append_string(seqnum_ti, " - OK");
/* Link to next SN in channel (if known) */
if (p->nextFrameNum != 0) {
@@ -2316,7 +2316,7 @@ static void dissect_rlc_lte_am(tvbuff_t *tvb, packet_info *pinfo,
write_pdu_label_and_info(top_ti, NULL, pinfo, (polling) ? " (P) " : " ");
if (polling) {
- proto_item_append_text(am_header_ti, " (P) ");
+ proto_item_append_string(am_header_ti, " (P) ");
}
/* Framing Info */
diff --git a/epan/dissectors/packet-wsp.c b/epan/dissectors/packet-wsp.c
index cef1082a0c..5af9b26704 100644
--- a/epan/dissectors/packet-wsp.c
+++ b/epan/dissectors/packet-wsp.c
@@ -4964,17 +4964,6 @@ dissect_wsp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* In the interest of speed, if "tree" is NULL, don't do any work not
* necessary to generate protocol tree items. */
if (tree) {
-
- /* We use proto_item_append_string() in a number of places.
- * It does not work with the TRY_TO_FAKE_THIS_ITEM speed
- * optimization, so we have to disable that one and become
- * "slow" by pretending that the tree is "visible".
- *
- * This code must be present for the MMSE dissector which
- * calls this function; otherwise, this causes a
- * dissector_assert [bug 492] (proto_item_append_string()
- * issue), and similar problems occur in other places.
- */
proto_tree_set_visible(tree, TRUE);
proto_ti = proto_tree_add_item(tree, proto_wsp,
diff --git a/epan/proto.c b/epan/proto.c
index 511c6d9dd0..e21bd0812d 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -2585,42 +2585,38 @@ proto_tree_add_string_format(proto_tree *tree, int hfindex, tvbuff_t *tvb,
* field info update instead of only updating the representation as does
* proto_item_append_text()
*/
-/* NOTE: this function will break with the TRY_TO_FAKE_THIS_ITEM()
- * speed optimization.
- * Currently only WSP use this function so it is not that bad but try to
- * avoid using this one if possible.
- * IF you must use this function you MUST also disable the
- * TRY_TO_FAKE_THIS_ITEM() optimization for your dissector/function
- * using proto_item_append_string().
- * Do that by faking that the tree is visible by calling
- * proto_tree_set_visible(tree, TRUE) (see packet-wsp.c)
- * BEFORE you create the item you are later going to use
- * proto_item_append_string() on.
- */
void
proto_item_append_string(proto_item *pi, const char *str)
{
- field_info *fi;
- header_field_info *hfinfo;
- gchar *old_str, *new_str;
+ field_info *fi = NULL;
+ size_t curlen;
- if (!pi)
- return;
- if (!*str)
+ if (pi == NULL) {
return;
+ }
fi = PITEM_FINFO(pi);
- DISSECTOR_ASSERT_HINT(fi, "proto_tree_set_visible(tree, TRUE) should have been called previously");
-
- hfinfo = fi->hfinfo;
- if (hfinfo->type == FT_PROTOCOL) {
- /* TRY_TO_FAKE_THIS_ITEM() speed optimization: silently skip */
+ if (fi == NULL) {
return;
}
- DISSECTOR_ASSERT(hfinfo->type == FT_STRING || hfinfo->type == FT_STRINGZ);
- old_str = fvalue_get(&fi->value);
- new_str = ep_strdup_printf("%s%s", old_str, str);
- fvalue_set(&fi->value, new_str, FALSE);
+
+ if (!PROTO_ITEM_IS_HIDDEN(pi)) {
+ /*
+ * If we don't already have a representation,
+ * generate the default representation.
+ */
+ if (fi->rep == NULL) {
+ ITEM_LABEL_NEW(fi->rep);
+ proto_item_fill_label(fi, fi->rep->representation);
+ }
+
+ curlen = strlen(fi->rep->representation);
+ if (ITEM_LABEL_LENGTH > curlen) {
+ g_strlcpy(fi->rep->representation + curlen,
+ str,
+ ITEM_LABEL_LENGTH - (gulong) curlen);
+ }
+ }
}
/* Set the FT_STRING value */