From 24e7627fe401834b3fa02c04934e36e55cd502a2 Mon Sep 17 00:00:00 2001 From: David Perry Date: Tue, 21 Nov 2023 16:34:03 -0500 Subject: Change some `wmem_packet_scope()` to `pinfo->pool` As requested [here][1], help with removing calls to `wmem_packet_scope()` in favour of references to `pinfo->pool`. * Plugins chosen semi-alphabetically. * When a calling function already has a `pinfo` argument, use that. * Remove `_U_` from its signature if it was there. * If a function seems narrowly focused on getting and (possibly) returning memory, change the function signature to take a `wmem_allocator_t *`. * If it seems more focused on packet-based operations, pass in a `packet_info *` instead and use `pinfo->pool` within. * Some of the files in this MR still have references to `wmem_packet_scope()` where it would take significant work to remove. These will need revisiting later. [1]: https://www.wireshark.org/lists/wireshark-dev/202107/msg00052.html --- epan/dissectors/packet-ieee80211-prism.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'epan/dissectors/packet-ieee80211-prism.c') diff --git a/epan/dissectors/packet-ieee80211-prism.c b/epan/dissectors/packet-ieee80211-prism.c index a9c638c355..edf1d493d6 100644 --- a/epan/dissectors/packet-ieee80211-prism.c +++ b/epan/dissectors/packet-ieee80211-prism.c @@ -246,10 +246,10 @@ prism_rate_base_custom(gchar *result, guint32 rate) } static gchar * -prism_rate_return(guint32 rate) +prism_rate_return(wmem_allocator_t *scope, guint32 rate) { gchar *result=NULL; - result = (gchar *)wmem_alloc(wmem_packet_scope(), SHORT_STR); + result = (gchar *)wmem_alloc(scope, SHORT_STR); result[0] = '\0'; prism_rate_base_custom(result, rate); @@ -392,7 +392,7 @@ static unsigned int vht_160_tbl[10][8] = static gchar * -prism_rate_return_sig(guint32 rate_phy1, guint32 rate_phy2, struct ieee_802_11_phdr *phdr) +prism_rate_return_sig(wmem_allocator_t *scope, guint32 rate_phy1, guint32 rate_phy2, struct ieee_802_11_phdr *phdr) { gchar *result = NULL; unsigned int mcs, base, pream_type, disp_rate, bw, sgi, ldpc, stbc, groupid, txbf; @@ -419,7 +419,7 @@ prism_rate_return_sig(guint32 rate_phy1, guint32 rate_phy2, struct ieee_802_11_p phdr->data_rate = mcs * 2; signal_type = rate_phy1 & (1 << 12); bw = 20 << ((rate_phy1 >> 13) & 0x3); - result = wmem_strdup_printf(wmem_packet_scope(), + result = wmem_strdup_printf(scope, "Rate: %u.%u Mb/s OFDM Signaling:%s BW %d", mcs, 0, signal_type ? "Dynamic" : "Static", bw ); @@ -436,7 +436,7 @@ prism_rate_return_sig(guint32 rate_phy1, guint32 rate_phy2, struct ieee_802_11_p disp_rate = dsss_tbl[mcs]; phdr->has_data_rate = 1; phdr->data_rate = disp_rate; - result = wmem_strdup_printf(wmem_packet_scope(), "Rate: %u.%u Mb/s DSSS %s", + result = wmem_strdup_printf(scope, "Rate: %u.%u Mb/s DSSS %s", disp_rate / 2, (disp_rate & 1) ? 5 : 0, base ? "[SP]" : "[LP]"); @@ -486,7 +486,7 @@ prism_rate_return_sig(guint32 rate_phy1, guint32 rate_phy2, struct ieee_802_11_p break; } } - result = wmem_strdup_printf(wmem_packet_scope(), + result = wmem_strdup_printf(scope, "Rate: %u.%u Mb/s HT MCS %d NSS %d BW %d MHz %s %s %s", disp_rate/10, disp_rate%10, mcs, nss, bw, sgi ? "[SGI]" : "", @@ -574,7 +574,7 @@ prism_rate_return_sig(guint32 rate_phy1, guint32 rate_phy2, struct ieee_802_11_p } } - result = wmem_strdup_printf(wmem_packet_scope(), + result = wmem_strdup_printf(scope, "Rate: %u.%u Mb/s VHT MCS %d NSS %d Partial AID %d BW %d MHz %s %s %s GroupID %d %s %s", disp_rate/10, disp_rate%10, mcs, nss, partial_aid, bw, @@ -590,7 +590,7 @@ prism_rate_return_sig(guint32 rate_phy1, guint32 rate_phy2, struct ieee_802_11_p nsts_u3 = (sig_a_1 >> 16) & 0x7; nsts_u4 = (sig_a_1 >> 19) & 0x7; - result = wmem_strdup_printf(wmem_packet_scope(), + result = wmem_strdup_printf(scope, "VHT NSTS %d %d %d %d BW %d MHz %s %s %s GroupID %d %s", nsts_u1, nsts_u2, nsts_u3, nsts_u4, bw, sgi ? "[SGI]" : "", @@ -702,7 +702,7 @@ dissect_prism(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U offset += 4; /* Device Name */ - proto_tree_add_item_ret_string(prism_tree, hf_ieee80211_prism_devname, tvb, offset, 16, ENC_ASCII|ENC_NA, wmem_packet_scope(), &devname_p); + proto_tree_add_item_ret_string(prism_tree, hf_ieee80211_prism_devname, tvb, offset, 16, ENC_ASCII|ENC_NA, pinfo->pool, &devname_p); offset += 16; col_add_fstr(pinfo->cinfo, COL_INFO, "Device: %s, Message 0x%x, Length %d", devname_p, msgcode, msglen); @@ -808,9 +808,9 @@ dissect_prism(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U phdr.data_rate = rate; if (tree) { proto_tree_add_item(prism_did_tree, hf_ieee80211_prism_did_rate, tvb, offset, 4, byte_order); - proto_item_append_text(ti_did, " %s Mb/s", prism_rate_return(rate)); + proto_item_append_text(ti_did, " %s Mb/s", prism_rate_return(pinfo->pool, rate)); } - col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%s", prism_rate_return(rate)); + col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%s", prism_rate_return(pinfo->pool, rate)); break; case PRISM_TYPE1_RATE_SIG_A1: @@ -848,7 +848,7 @@ dissect_prism(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U proto_item_append_text(ti_did, " 0x%x", tvb_get_letohl(tvb, offset)); sig_sub_item = proto_tree_add_item(prism_tree, hf_ieee80211_prism_did_sig_rate_field, tvb, offset, 4, byte_order); - proto_item_append_text(sig_sub_item, " %s", prism_rate_return_sig(rate_phy1, rate_phy2, &phdr)); + proto_item_append_text(sig_sub_item, " %s", prism_rate_return_sig(pinfo->pool, rate_phy1, rate_phy2, &phdr)); } break; -- cgit v1.2.3