aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/wtap.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-05-15 23:39:12 +0200
committerMichael Mann <mmann78@netscape.net>2014-05-17 12:41:50 +0000
commit3aee917058fb46b2e86d750766001c4db214fc78 (patch)
treeab3cf638836b2dd9c1fc53e90c01cefe129989ae /wiretap/wtap.c
parent9fe221a42f6085d6345a5ee6b5deb47d93b264de (diff)
wiretap: remove unused code, drop number_of_interfaces
While investigating an ASAN issue (fixed in commit dcdd076ab0965c346efe90051678ba790eaf7a02), I got greatly confused by three different types having the same "interface_data" field name: * pcapng_t *pn stores an array of interface_data_t objects. * wtap *wth stores an array of wtapng_if_descr_t objects. * pcapng_dump_t should store an array of interface_data_t objects. pcapng_dump_t and friends are unused since commit c7f1a431d23e17a15777652b1252e139f182b0e6, so drop it. To fix the confusion, rename the interface_data_t type to interface_info_t type and use the local variable "iface_info" everywhere. Rename interface_data of pcapng_t to "interfaces" and add a comment what this exactly means (interfaces listed in the capture file). Drop the number_of_interfaces field for interfaces as the array length is already available from GArray. Now interface_data is always initialized for wth (which also gets copied to idb). s/int/guint/g and replace cast at some places. There are no regressions for the in-tree test suite. Change-Id: I2d5985c9f1e43f8230dbb4a73bd1e243c4858170 Reviewed-on: https://code.wireshark.org/review/1656 Reviewed-by: Evan Huus <eapache@gmail.com> Tested-by: Evan Huus <eapache@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'wiretap/wtap.c')
-rw-r--r--wiretap/wtap.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 403734706c..c32524be80 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -201,7 +201,6 @@ wtap_file_get_idb_info(wtap *wth)
idb_info = g_new(wtapng_iface_descriptions_t,1);
- idb_info->number_of_interfaces = wth->number_of_interfaces;
idb_info->interface_data = wth->interface_data;
return idb_info;
@@ -907,7 +906,7 @@ wtap_fdclose(wtap *wth)
void
wtap_close(wtap *wth)
{
- gint i, j;
+ guint i, j;
wtapng_if_descr_t *wtapng_if_descr;
wtapng_if_stats_t *if_stats;
@@ -926,7 +925,7 @@ wtap_close(wtap *wth)
g_ptr_array_foreach(wth->fast_seek, g_fast_seek_item_free, NULL);
g_ptr_array_free(wth->fast_seek, TRUE);
}
- for(i = 0; i < (gint)wth->number_of_interfaces; i++) {
+ for(i = 0; i < wth->interface_data->len; i++) {
wtapng_if_descr = &g_array_index(wth->interface_data, wtapng_if_descr_t, i);
if(wtapng_if_descr->opt_comment != NULL){
g_free(wtapng_if_descr->opt_comment);
@@ -946,19 +945,17 @@ wtap_close(wtap *wth)
if(wtapng_if_descr->if_os != NULL){
g_free(wtapng_if_descr->if_os);
}
- for(j = 0; j < (gint)wtapng_if_descr->num_stat_entries; j++) {
+ for(j = 0; j < wtapng_if_descr->num_stat_entries; j++) {
if_stats = &g_array_index(wtapng_if_descr->interface_statistics, wtapng_if_stats_t, j);
if(if_stats->opt_comment != NULL){
g_free(if_stats->opt_comment);
}
}
if(wtapng_if_descr->num_stat_entries != 0){
- g_array_free(wtapng_if_descr->interface_statistics, TRUE);
+ g_array_free(wtapng_if_descr->interface_statistics, TRUE);
}
}
- if(wth->number_of_interfaces != 0){
- g_array_free(wth->interface_data, TRUE);
- }
+ g_array_free(wth->interface_data, TRUE);
g_free(wth);
}