summaryrefslogtreecommitdiff
path: root/epan
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2016-01-20 03:11:16 +0000
committerJoão Valverde <j@v6e.pt>2016-01-21 02:30:18 +0000
commit4dd3f668dc9a86be0353d9572d9624bb7cca9bf5 (patch)
treee7f7923826d4024d884047f270cc37c47669e1a6 /epan
parent770eb649d847b620b5bc820a5cc6eef6e4c2d330 (diff)
downloadwireshark-4dd3f668dc9a86be0353d9572d9624bb7cca9bf5.tar.gz
Avoid returning malloced memory as const [-Wcast-qual]
Change-Id: I0b2c03cbde963d13d07ef13284d85b922eec3be9 Reviewed-on: https://code.wireshark.org/review/13439 Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'epan')
-rw-r--r--epan/conversation_table.c15
-rw-r--r--epan/conversation_table.h8
2 files changed, 12 insertions, 11 deletions
diff --git a/epan/conversation_table.c b/epan/conversation_table.c
index 04f8620001..a7e7cb1943 100644
--- a/epan/conversation_table.c
+++ b/epan/conversation_table.c
@@ -324,7 +324,7 @@ void reset_hostlist_table_data(conv_hash_t *ch)
ch->hashtable=NULL;
}
-const char *get_conversation_address(wmem_allocator_t *allocator, address *addr, gboolean resolve_names)
+char *get_conversation_address(wmem_allocator_t *allocator, address *addr, gboolean resolve_names)
{
if (resolve_names) {
return address_to_display(allocator, addr);
@@ -333,7 +333,7 @@ const char *get_conversation_address(wmem_allocator_t *allocator, address *addr,
}
}
-const char *get_conversation_port(wmem_allocator_t *allocator, guint32 port, port_type ptype, gboolean resolve_names)
+char *get_conversation_port(wmem_allocator_t *allocator, guint32 port, port_type ptype, gboolean resolve_names)
{
if(!resolve_names) ptype = PT_NONE;
@@ -396,10 +396,10 @@ ct_port_to_str(port_type ptype, guint32 port)
return NULL;
}
-const char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction)
+char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction)
{
char *sport, *dport, *src_addr, *dst_addr;
- const char *str = "INVALID";
+ char *str;
sport = ct_port_to_str(conv_item->ptype, conv_item->src_port);
dport = ct_port_to_str(conv_item->ptype, conv_item->dst_port);
@@ -540,6 +540,7 @@ const char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e dir
);
break;
default:
+ str = wmem_strdup(NULL, "INVALID");
break;
}
g_free(sport);
@@ -549,12 +550,12 @@ const char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e dir
return str;
}
-const char *get_hostlist_filter(hostlist_talker_t *host)
+char *get_hostlist_filter(hostlist_talker_t *host)
{
char *sport, *src_addr;
- const char *str;
+ char *str;
- sport=ct_port_to_str(host->ptype, host->port);
+ sport = ct_port_to_str(host->ptype, host->port);
src_addr = address_to_str(NULL, &host->myaddress);
if (host->myaddress.type == AT_STRINGZ || host->myaddress.type == AT_USB) {
char *new_addr;
diff --git a/epan/conversation_table.h b/epan/conversation_table.h
index 5c5699dad5..c0871924e2 100644
--- a/epan/conversation_table.h
+++ b/epan/conversation_table.h
@@ -258,7 +258,7 @@ WS_DLL_PUBLIC void dissector_hostlist_init(const char *opt_arg, void* userdata);
* @param resolve_names Enable name resolution.
* @return A string representing the address.
*/
-WS_DLL_PUBLIC const char *get_conversation_address(wmem_allocator_t *allocator, address *addr, gboolean resolve_names);
+WS_DLL_PUBLIC char *get_conversation_address(wmem_allocator_t *allocator, address *addr, gboolean resolve_names);
/** Get the string representation of a port.
*
@@ -268,7 +268,7 @@ WS_DLL_PUBLIC const char *get_conversation_address(wmem_allocator_t *allocator,
* @param resolve_names Enable name resolution.
* @return A string representing the port.
*/
-WS_DLL_PUBLIC const char *get_conversation_port(wmem_allocator_t *allocator, guint32 port, port_type ptype, gboolean resolve_names);
+WS_DLL_PUBLIC char *get_conversation_port(wmem_allocator_t *allocator, guint32 port, port_type ptype, gboolean resolve_names);
/** Get a display filter for the given conversation and direction.
*
@@ -276,7 +276,7 @@ WS_DLL_PUBLIC const char *get_conversation_port(wmem_allocator_t *allocator, gui
* @param direction The desired direction.
* @return An g_allocated string representing the conversation that must be freed
*/
-WS_DLL_PUBLIC const char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction);
+WS_DLL_PUBLIC char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction);
/** Get a display filter for the given hostlist.
*
@@ -284,7 +284,7 @@ WS_DLL_PUBLIC const char *get_conversation_filter(conv_item_t *conv_item, conv_d
* @return A string, allocated using the wmem NULL allocator,
* representing the conversation.
*/
-WS_DLL_PUBLIC const char *get_hostlist_filter(hostlist_talker_t *host);
+WS_DLL_PUBLIC char *get_hostlist_filter(hostlist_talker_t *host);
/** Add some data to the conversation table.
*