diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2015-11-27 23:04:16 +0000 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2015-11-29 00:25:11 +0000 |
commit | 5e6d45ca98bb8c368b73084785d90fa3b0b6291f (patch) | |
tree | 7e541c16d0e31ef60e35d2be7ba27f8a477523cc | |
parent | cfc47c15c2b902a50764a21cbcd2ba1d78b1de7a (diff) |
Make address_to_display() use proper (non-)constness
Don't return allocated memory as a const pointer.
Fixes multiple [-Wcast-qual] warnings.
Change-Id: Ie9ceac27fa2a5eba41a5392ac983ff28c3939239
Reviewed-on: https://code.wireshark.org/review/12267
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r-- | epan/address_types.c | 2 | ||||
-rw-r--r-- | epan/to_str.h | 2 | ||||
-rw-r--r-- | ui/cli/tap-rtp.c | 4 | ||||
-rw-r--r-- | ui/gtk/graph_analysis.c | 2 | ||||
-rw-r--r-- | ui/gtk/iax2_analysis.c | 24 | ||||
-rw-r--r-- | ui/gtk/mcast_stream_dlg.c | 8 | ||||
-rw-r--r-- | ui/gtk/rtp_analysis.c | 24 | ||||
-rw-r--r-- | ui/gtk/rtp_player.c | 8 | ||||
-rw-r--r-- | ui/gtk/rtp_stream_dlg.c | 12 | ||||
-rw-r--r-- | ui/gtk/voip_calls_dlg.c | 2 | ||||
-rw-r--r-- | ui/qt/sequence_diagram.cpp | 2 | ||||
-rw-r--r-- | ui/qt/sequence_dialog.cpp | 2 | ||||
-rw-r--r-- | ui/tap-rtp-common.c | 2 | ||||
-rw-r--r-- | ui/tap-sequence-analysis.c | 4 | ||||
-rw-r--r-- | ui/traffic_table_ui.c | 2 |
15 files changed, 50 insertions, 50 deletions
diff --git a/epan/address_types.c b/epan/address_types.c index 29fca975f1..e84be71ad6 100644 --- a/epan/address_types.c +++ b/epan/address_types.c @@ -961,7 +961,7 @@ address_to_name(const address *addr) } } -const gchar * +gchar * address_to_display(wmem_allocator_t *allocator, const address *addr) { gchar *str = NULL; diff --git a/epan/to_str.h b/epan/to_str.h index 7475b0c672..d6ecde434c 100644 --- a/epan/to_str.h +++ b/epan/to_str.h @@ -80,7 +80,7 @@ const gchar *address_to_name(const address *addr); * e.g. "10.10.10.10" for IPv4 address 10.10.10.10. */ WS_DLL_PUBLIC -const gchar *address_to_display(wmem_allocator_t *allocator, const address *addr); +gchar *address_to_display(wmem_allocator_t *allocator, const address *addr); WS_DLL_PUBLIC void address_to_str_buf(const address *addr, gchar *buf, int buf_len); diff --git a/ui/cli/tap-rtp.c b/ui/cli/tap-rtp.c index 98190a0632..c7a87214f0 100644 --- a/ui/cli/tap-rtp.c +++ b/ui/cli/tap-rtp.c @@ -103,8 +103,8 @@ rtp_streams_stat_draw(void *arg _U_) perc = 0; } - src_addr = (char*)address_to_display(NULL, &(strinfo->src_addr)); - dst_addr = (char*)address_to_display(NULL, &(strinfo->dest_addr)); + src_addr = address_to_display(NULL, &(strinfo->src_addr)); + dst_addr = address_to_display(NULL, &(strinfo->dest_addr)); printf("%15s %5u %15s %5u 0x%08X %16s %5u %5d (%.1f%%) %15.2f %15.2f %15.2f %s\n", src_addr, strinfo->src_port, diff --git a/ui/gtk/graph_analysis.c b/ui/gtk/graph_analysis.c index 5aa85eaa55..b8b78cb816 100644 --- a/ui/gtk/graph_analysis.c +++ b/ui/gtk/graph_analysis.c @@ -622,7 +622,7 @@ static void dialog_graph_draw(graph_analysis_data_t *user_data) /* print the node identifiers */ /* XXX we assign 5 pixels per character in the node identity */ - addr_str = (char*)address_to_display(NULL, &(user_data->graph_info->nodes[i])); + addr_str = address_to_display(NULL, &(user_data->graph_info->nodes[i])); g_strlcpy(label_string, addr_str, NODE_WIDTH/5); wmem_free(NULL, addr_str); pango_layout_set_text(layout, label_string, -1); diff --git a/ui/gtk/iax2_analysis.c b/ui/gtk/iax2_analysis.c index 66eaa00ee5..c783112910 100644 --- a/ui/gtk/iax2_analysis.c +++ b/ui/gtk/iax2_analysis.c @@ -728,10 +728,10 @@ dialog_graph_set_title(user_data_t* user_data) return; } - src_fwd_addr = (char*)address_to_display(NULL, &(user_data->ip_src_fwd)); - dst_fwd_addr = (char*)address_to_display(NULL, &(user_data->ip_dst_fwd)); - src_rev_addr = (char*)address_to_display(NULL, &(user_data->ip_src_rev)); - dst_rev_addr = (char*)address_to_display(NULL, &(user_data->ip_dst_rev)); + src_fwd_addr = address_to_display(NULL, &(user_data->ip_src_fwd)); + dst_fwd_addr = address_to_display(NULL, &(user_data->ip_dst_fwd)); + src_rev_addr = address_to_display(NULL, &(user_data->ip_src_rev)); + dst_rev_addr = address_to_display(NULL, &(user_data->ip_dst_rev)); title = g_strdup_printf("IAX2 Graph Analysis Forward: %s:%u to %s:%u Reverse: %s:%u to %s:%u", src_fwd_addr, user_data->port_src_fwd, @@ -776,8 +776,8 @@ dialog_graph_reset(user_data_t* user_data) for (i = 0; i < MAX_GRAPHS; i++) { /* it is forward */ if (i < 2) { - src_addr = (char*)address_to_display(NULL, &(user_data->ip_src_fwd)); - dst_addr = (char*)address_to_display(NULL, &(user_data->ip_dst_fwd)); + src_addr = address_to_display(NULL, &(user_data->ip_src_fwd)); + dst_addr = address_to_display(NULL, &(user_data->ip_dst_fwd)); g_snprintf(user_data->dlg.dialog_graph.graph[i].title, sizeof (user_data->dlg.dialog_graph.graph[0].title), "%s: %s:%u to %s:%u", @@ -788,8 +788,8 @@ dialog_graph_reset(user_data_t* user_data) user_data->port_dst_fwd); /* it is reverse */ } else { - src_addr = (char*)address_to_display(NULL, &(user_data->ip_src_rev)); - dst_addr = (char*)address_to_display(NULL, &(user_data->ip_dst_rev)); + src_addr = address_to_display(NULL, &(user_data->ip_src_rev)); + dst_addr = address_to_display(NULL, &(user_data->ip_dst_rev)); g_snprintf(user_data->dlg.dialog_graph.graph[i].title, sizeof(user_data->dlg.dialog_graph.graph[0].title), "%s: %s:%u to %s:%u", @@ -3247,16 +3247,16 @@ create_iax2_dialog(user_data_t* user_data) gtk_widget_show(main_vb); /* Notebooks... */ - src_addr = (char*)address_to_display(NULL, &(user_data->ip_src_fwd)); - dst_addr = (char*)address_to_display(NULL, &(user_data->ip_dst_fwd)); + src_addr = address_to_display(NULL, &(user_data->ip_src_fwd)); + dst_addr = address_to_display(NULL, &(user_data->ip_dst_fwd)); g_snprintf(label_forward, sizeof(label_forward), "Analysing stream from %s port %u to %s port %u ", src_addr, user_data->port_src_fwd, dst_addr, user_data->port_dst_fwd); wmem_free(NULL, src_addr); wmem_free(NULL, dst_addr); - src_addr = (char*)address_to_display(NULL, &(user_data->ip_src_rev)); - dst_addr = (char*)address_to_display(NULL, &(user_data->ip_dst_rev)); + src_addr = address_to_display(NULL, &(user_data->ip_src_rev)); + dst_addr = address_to_display(NULL, &(user_data->ip_dst_rev)); g_snprintf(label_reverse, sizeof(label_reverse), "Analysing stream from %s port %u to %s port %u ", src_addr, user_data->port_src_rev, dst_addr, user_data->port_dst_rev); diff --git a/ui/gtk/mcast_stream_dlg.c b/ui/gtk/mcast_stream_dlg.c index 16ad6efd12..f5ae26ac16 100644 --- a/ui/gtk/mcast_stream_dlg.c +++ b/ui/gtk/mcast_stream_dlg.c @@ -187,8 +187,8 @@ mcaststream_on_select_row(GtkTreeSelection *selection, gpointer data _U_) if (gtk_tree_selection_get_selected(selection, NULL, &list_iter)) { gtk_tree_model_get(GTK_TREE_MODEL(list_store), &list_iter, MC_COL_DATA, &selected_stream_fwd, -1); - src_addr = (char*)address_to_display(NULL, &(selected_stream_fwd->src_addr)); - dst_addr = (char*)address_to_display(NULL, &(selected_stream_fwd->dest_addr)); + src_addr = address_to_display(NULL, &(selected_stream_fwd->src_addr)); + dst_addr = address_to_display(NULL, &(selected_stream_fwd->dest_addr)); g_snprintf(label_text, sizeof(label_text), "Selected: %s:%u -> %s:%u", src_addr, selected_stream_fwd->src_port, @@ -389,8 +389,8 @@ add_to_list_store(mcast_stream_info_t* strinfo) in g_snprintf("%f") functions */ setlocale(LC_NUMERIC, "C"); - src_addr = (char*)address_to_display(NULL, &(strinfo->src_addr)); - dst_addr = (char*)address_to_display(NULL, &(strinfo->dest_addr)); + src_addr = address_to_display(NULL, &(strinfo->src_addr)); + dst_addr = address_to_display(NULL, &(strinfo->dest_addr)); data[0] = g_strdup(src_addr); data[1] = g_strdup_printf("%u", strinfo->src_port); data[2] = g_strdup(dst_addr); diff --git a/ui/gtk/rtp_analysis.c b/ui/gtk/rtp_analysis.c index 2d484ec0ef..0058e97960 100644 --- a/ui/gtk/rtp_analysis.c +++ b/ui/gtk/rtp_analysis.c @@ -863,10 +863,10 @@ dialog_graph_set_title(user_data_t* user_data) return; } - src_fwd_addr = (char*)address_to_display(NULL, &(user_data->src_fwd)); - dst_fwd_addr = (char*)address_to_display(NULL, &(user_data->dst_fwd)); - src_rev_addr = (char*)address_to_display(NULL, &(user_data->src_rev)); - dst_rev_addr = (char*)address_to_display(NULL, &(user_data->dst_rev)); + src_fwd_addr = address_to_display(NULL, &(user_data->src_fwd)); + dst_fwd_addr = address_to_display(NULL, &(user_data->dst_fwd)); + src_rev_addr = address_to_display(NULL, &(user_data->src_rev)); + dst_rev_addr = address_to_display(NULL, &(user_data->dst_rev)); title = g_strdup_printf("RTP Graph Analysis Forward: %s:%u to %s:%u Reverse: %s:%u to %s:%u", src_fwd_addr, user_data->port_src_fwd, @@ -910,8 +910,8 @@ dialog_graph_reset(user_data_t* user_data) for (i = 0; i < MAX_GRAPHS; i++) { /* it is forward */ if (i < (MAX_GRAPHS/2)) { - src_addr = (char*)address_to_display(NULL, &(user_data->src_fwd)); - dst_addr = (char*)address_to_display(NULL, &(user_data->dst_fwd)); + src_addr = address_to_display(NULL, &(user_data->src_fwd)); + dst_addr = address_to_display(NULL, &(user_data->dst_fwd)); g_snprintf(user_data->dlg.dialog_graph.graph[i].title, sizeof(user_data->dlg.dialog_graph.graph[0].title), "%s: %s:%u to %s:%u (SSRC=0x%X)", @@ -923,8 +923,8 @@ dialog_graph_reset(user_data_t* user_data) user_data->ssrc_fwd); /* it is reverse */ } else { - src_addr = (char*)address_to_display(NULL, &(user_data->src_rev)); - dst_addr = (char*)address_to_display(NULL, &(user_data->dst_rev)); + src_addr = address_to_display(NULL, &(user_data->src_rev)); + dst_addr = address_to_display(NULL, &(user_data->dst_rev)); g_snprintf(user_data->dlg.dialog_graph.graph[i].title, sizeof(user_data->dlg.dialog_graph.graph[0].title), "%s: %s:%u to %s:%u (SSRC=0x%X)", @@ -3550,8 +3550,8 @@ create_rtp_dialog(user_data_t* user_data) gtk_widget_show(main_vb); /* Notebooks... */ - src_addr = (char*)address_to_display(NULL, &(user_data->src_fwd)); - dst_addr = (char*)address_to_display(NULL, &(user_data->dst_fwd)); + src_addr = address_to_display(NULL, &(user_data->src_fwd)); + dst_addr = address_to_display(NULL, &(user_data->dst_fwd)); g_snprintf(label_forward, sizeof(label_forward), "Analysing stream from %s port %u to %s port %u SSRC = 0x%X", src_addr, user_data->port_src_fwd, dst_addr, user_data->port_dst_fwd, user_data->ssrc_fwd); @@ -3563,8 +3563,8 @@ create_rtp_dialog(user_data_t* user_data) wmem_free(NULL, src_addr); wmem_free(NULL, dst_addr); - src_addr = (char*)address_to_display(NULL, &(user_data->src_rev)); - dst_addr = (char*)address_to_display(NULL, &(user_data->dst_rev)); + src_addr = address_to_display(NULL, &(user_data->src_rev)); + dst_addr = address_to_display(NULL, &(user_data->dst_rev)); g_snprintf(label_reverse, sizeof(label_reverse), "Analysing stream from %s port %u to %s port %u SSRC = 0x%X \n" "Note many things affects the accuracy of the analysis, use with caution", diff --git a/ui/gtk/rtp_player.c b/ui/gtk/rtp_player.c index 08d7344581..45f34c7b7c 100644 --- a/ui/gtk/rtp_player.c +++ b/ui/gtk/rtp_player.c @@ -506,8 +506,8 @@ decode_rtp_stream(rtp_stream_info_t *rsi, gpointer ptr) * uses: src_ip:src_port dst_ip:dst_port call_num */ key_str = g_string_new(""); - src_addr = (char*)address_to_display(NULL, &(rsi->src_addr)); - dst_addr = (char*)address_to_display(NULL, &(rsi->dest_addr)); + src_addr = address_to_display(NULL, &(rsi->src_addr)); + dst_addr = address_to_display(NULL, &(rsi->dest_addr)); g_string_printf(key_str, "%s:%d %s:%d %d %u", src_addr, rsi->src_port, dst_addr, rsi->dest_port, rsi->call_num, info->current_channel); @@ -1751,8 +1751,8 @@ add_channel_to_window(gchar *key _U_ , rtp_channel_info_t *rci, guint *counter) label = g_string_new(""); - src_addr = (char*)address_to_display(NULL, &(rci->first_stream->src_addr)); - dst_addr = (char*)address_to_display(NULL, &(rci->first_stream->dest_addr)); + src_addr = address_to_display(NULL, &(rci->first_stream->src_addr)); + dst_addr = address_to_display(NULL, &(rci->first_stream->dest_addr)); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb_use_rtp_timestamp))) { g_string_printf(label, "From %s:%d to %s:%d Duration:%.2f Out of Seq: %d(%.1f%%) Wrong Timestamp: %d(%.1f%%)", src_addr, rci->first_stream->src_port, diff --git a/ui/gtk/rtp_stream_dlg.c b/ui/gtk/rtp_stream_dlg.c index a53aaaef6e..e87549ea43 100644 --- a/ui/gtk/rtp_stream_dlg.c +++ b/ui/gtk/rtp_stream_dlg.c @@ -635,8 +635,8 @@ rtpstream_view_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, } if (selected_stream_fwd) { - src_addr = (char*)address_to_display(NULL, &(selected_stream_fwd->src_addr)); - dst_addr = (char*)address_to_display(NULL, &(selected_stream_fwd->dest_addr)); + src_addr = address_to_display(NULL, &(selected_stream_fwd->src_addr)); + dst_addr = address_to_display(NULL, &(selected_stream_fwd->dest_addr)); g_snprintf(label_text, sizeof(label_text), "Forward: %s:%u -> %s:%u, SSRC=0x%X", src_addr, @@ -657,8 +657,8 @@ rtpstream_view_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, } if (selected_stream_rev) { - src_addr = (char*)address_to_display(NULL, &(selected_stream_rev->src_addr)); - dst_addr = (char*)address_to_display(NULL, &(selected_stream_rev->dest_addr)); + src_addr = address_to_display(NULL, &(selected_stream_rev->src_addr)); + dst_addr = address_to_display(NULL, &(selected_stream_rev->dest_addr)); g_snprintf(label_text, sizeof(label_text), "Reverse: %s:%u -> %s:%u, SSRC=0x%X", src_addr, @@ -700,9 +700,9 @@ add_to_list_store(rtp_stream_info_t* strinfo) in g_snprintf("%f") functions */ setlocale(LC_NUMERIC, "C"); - data[0] = (gchar*)address_to_display(NULL, &(strinfo->src_addr)); + data[0] = address_to_display(NULL, &(strinfo->src_addr)); data[1] = NULL; - data[2] = (gchar*)address_to_display(NULL, &(strinfo->dest_addr)); + data[2] = address_to_display(NULL, &(strinfo->dest_addr)); data[3] = NULL; data[4] = wmem_strdup_printf(NULL, "0x%X", strinfo->ssrc); if (strinfo->payload_type_name != NULL) { diff --git a/ui/gtk/voip_calls_dlg.c b/ui/gtk/voip_calls_dlg.c index 53bc752321..af92525116 100644 --- a/ui/gtk/voip_calls_dlg.c +++ b/ui/gtk/voip_calls_dlg.c @@ -445,7 +445,7 @@ add_to_list_store(voip_calls_info_t* strinfo) isup_calls_info_t *isupinfo; h323_calls_info_t *h323info; gboolean flag = FALSE; - char* addr_str = (char*)address_to_display(NULL, &(strinfo->initial_speaker)); + char* addr_str = address_to_display(NULL, &(strinfo->initial_speaker)); g_snprintf(field[CALL_COL_INITIAL_SPEAKER], 30, "%s", addr_str); g_snprintf(field[CALL_COL_FROM], 50, "%s", strinfo->from_identity); diff --git a/ui/qt/sequence_diagram.cpp b/ui/qt/sequence_diagram.cpp index 5c1fe116bf..764474b3e7 100644 --- a/ui/qt/sequence_diagram.cpp +++ b/ui/qt/sequence_diagram.cpp @@ -133,7 +133,7 @@ void SequenceDiagram::setData(_seq_analysis_info *sainfo) for (unsigned int i = 0; i < sainfo_->num_nodes; i++) { val_ticks.append(i); - addr_str = (char*)address_to_display(NULL, &(sainfo_->nodes[i])); + addr_str = address_to_display(NULL, &(sainfo_->nodes[i])); val_labels.append(addr_str); if (i % 2 == 0) { val_labels.last().append("\n"); diff --git a/ui/qt/sequence_dialog.cpp b/ui/qt/sequence_dialog.cpp index 50f7e6ec9a..fecb40dad0 100644 --- a/ui/qt/sequence_dialog.cpp +++ b/ui/qt/sequence_dialog.cpp @@ -353,7 +353,7 @@ void SequenceDialog::fillDiagram() char* addr_str; node_label_w_ = 0; for (guint i = 0; i < info_->sainfo()->num_nodes; i++) { - addr_str = (char*)address_to_display(NULL, &(info_->sainfo()->nodes[i])); + addr_str = address_to_display(NULL, &(info_->sainfo()->nodes[i])); int label_w = vfm.width(addr_str); if (node_label_w_ < label_w) { node_label_w_ = label_w; diff --git a/ui/tap-rtp-common.c b/ui/tap-rtp-common.c index 2643ee343d..8b42c3a215 100644 --- a/ui/tap-rtp-common.c +++ b/ui/tap-rtp-common.c @@ -140,7 +140,7 @@ void rtp_write_header(rtp_stream_info_t *strinfo, FILE *file) size_t sourcelen; guint16 port; /* UDP port */ guint16 padding; /* 2 padding bytes */ - char* addr_str = (char*)address_to_display(NULL, &(strinfo->dest_addr)); + char* addr_str = address_to_display(NULL, &(strinfo->dest_addr)); fprintf(file, "#!rtpplay%s %s/%u\n", RTPFILE_VERSION, addr_str, diff --git a/ui/tap-sequence-analysis.c b/ui/tap-sequence-analysis.c index 9ea84ee3dd..d9538bb180 100644 --- a/ui/tap-sequence-analysis.c +++ b/ui/tap-sequence-analysis.c @@ -553,7 +553,7 @@ sequence_analysis_dump_to_file(const char *pathname, seq_analysis_info_t *sainfo /* Write the node names on top */ for (i=0; i<display_nodes; i+=2) { /* print the node identifiers */ - addr_str = (char*)address_to_display(NULL, &(sainfo->nodes[i+first_node])); + addr_str = address_to_display(NULL, &(sainfo->nodes[i+first_node])); g_string_printf(label_string, "| %s", addr_str); wmem_free(NULL, addr_str); enlarge_string(label_string, NODE_CHARS_WIDTH*2, ' '); @@ -571,7 +571,7 @@ sequence_analysis_dump_to_file(const char *pathname, seq_analysis_info_t *sainfo /* Write the node names on top */ for (i=1; i<display_nodes; i+=2) { /* print the node identifiers */ - addr_str = (char*)address_to_display(NULL, &(sainfo->nodes[i+first_node])); + addr_str = address_to_display(NULL, &(sainfo->nodes[i+first_node])); g_string_printf(label_string, "| %s", addr_str); wmem_free(NULL, addr_str); if (label_string->len < NODE_CHARS_WIDTH) diff --git a/ui/traffic_table_ui.c b/ui/traffic_table_ui.c index b76f15830c..fb37ab74c6 100644 --- a/ui/traffic_table_ui.c +++ b/ui/traffic_table_ui.c @@ -228,7 +228,7 @@ create_endpoint_geoip_map(const GArray *endp_array, gchar **err_str) { g_string_append_printf(tpl_entry, " 'type': 'Feature', 'geometry': { 'type': 'Point', 'coordinates': [%s, %s] },\n", lon, lat); /* Address */ - addr_str = (char*)address_to_display(NULL, &endp_item->myaddress); + addr_str = address_to_display(NULL, &endp_item->myaddress); g_string_append_printf(tpl_entry, " 'properties': { 'title': '%s', ", addr_str); wmem_free(NULL, addr_str); |