From fd6f84b46dcad8664f180830b9951f72a255f41e Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 14 Jan 2005 20:27:34 +0000 Subject: From Laurent Rabret: handle the cases where there's no capture file, or there is but it has no packets. svn path=/trunk/; revision=13041 --- gtk/ansi_a_stat.c | 4 ++-- gtk/ansi_map_stat.c | 2 +- gtk/gsm_a_stat.c | 2 ++ gtk/gsm_map_stat.c | 2 +- gtk/isup_stat.c | 2 +- gtk/mtp3_stat.c | 2 +- gtk/mtp3_summary.c | 45 +++++++++++++++++++++++++++++++-------------- 7 files changed, 39 insertions(+), 20 deletions(-) diff --git a/gtk/ansi_a_stat.c b/gtk/ansi_a_stat.c index 4f78e3e754..f34754ada9 100644 --- a/gtk/ansi_a_stat.c +++ b/gtk/ansi_a_stat.c @@ -128,7 +128,7 @@ ansi_a_stat_draw( int i, j; char *strp; - if (dlg_bsmap.win != NULL) + if (dlg_bsmap.win && tapdata) { i = 0; @@ -147,7 +147,7 @@ ansi_a_stat_draw( gtk_clist_sort(GTK_CLIST(dlg_bsmap.table)); } - if (dlg_dtap.win != NULL) + if (dlg_dtap.win && tapdata) { i = 0; diff --git a/gtk/ansi_map_stat.c b/gtk/ansi_map_stat.c index d54850dfd7..16bc2b76a6 100644 --- a/gtk/ansi_map_stat.c +++ b/gtk/ansi_map_stat.c @@ -137,7 +137,7 @@ ansi_map_stat_draw( int i, j; char *strp; - if (dlg.win != NULL) + if (dlg.win && tapdata) { i = 0; diff --git a/gtk/gsm_a_stat.c b/gtk/gsm_a_stat.c index b39ba53e1a..b45d2a93d5 100644 --- a/gtk/gsm_a_stat.c +++ b/gtk/gsm_a_stat.c @@ -195,6 +195,8 @@ gsm_a_stat_draw( { gsm_a_stat_t *stat_p = tapdata; + if (!tapdata) return; + if (dlg_bssmap.win != NULL) { gsm_a_stat_draw_aux(&dlg_bssmap, diff --git a/gtk/gsm_map_stat.c b/gtk/gsm_map_stat.c index a154c20bf4..883fe71305 100644 --- a/gtk/gsm_map_stat.c +++ b/gtk/gsm_map_stat.c @@ -150,7 +150,7 @@ gsm_map_stat_draw( int i, j; char *strp; - if (dlg.win != NULL) + if (dlg.win && tapdata) { i = 0; diff --git a/gtk/isup_stat.c b/gtk/isup_stat.c index beda73bc53..befac9102a 100644 --- a/gtk/isup_stat.c +++ b/gtk/isup_stat.c @@ -120,7 +120,7 @@ isup_stat_draw( int i, j; char *strp; - if (dlg.win != NULL) + if (dlg.win && tapdata) { i = 0; diff --git a/gtk/mtp3_stat.c b/gtk/mtp3_stat.c index c77c51d036..76b9206704 100644 --- a/gtk/mtp3_stat.c +++ b/gtk/mtp3_stat.c @@ -174,7 +174,7 @@ mtp3_stat_draw( int i, j, row_offset; char str[256]; - if (dlg.win == NULL) + if (!dlg.win || !tapdata) { return; } diff --git a/gtk/mtp3_summary.c b/gtk/mtp3_summary.c index bb3524fae1..2db1066477 100644 --- a/gtk/mtp3_summary.c +++ b/gtk/mtp3_summary.c @@ -217,13 +217,13 @@ mtp3_sum_draw( entries[1] = g_strdup_printf("%u", num_msus); - entries[2] = g_strdup_printf("%.2f", num_msus/seconds); - + entries[2] = (seconds) ? g_strdup_printf("%.2f", num_msus/seconds) : "N/A"; + entries[3] = g_strdup_printf("%.0f", num_bytes); - entries[4] = g_strdup_printf("%.2f", num_bytes/num_msus); + entries[4] = (num_msus) ? g_strdup_printf("%.2f", num_bytes/num_msus) : "N/A"; - entries[5] = g_strdup_printf("%.2f", num_bytes/seconds); + entries[5] = (seconds) ? g_strdup_printf("%.2f", num_bytes/seconds) : "N/A"; gtk_clist_insert(GTK_CLIST(table), i, entries); } @@ -243,11 +243,12 @@ mtp3_sum_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_) *table, *column_lb, *table_fr; column_arrows *col_arrows; - gchar string_buff[SUM_STR_MAX]; - double seconds; - int tot_num_msus; - double tot_num_bytes; - int i; + gchar string_buff[SUM_STR_MAX]; + const char * file_type; + double seconds; + int tot_num_msus; + double tot_num_bytes; + int i; /* initialize the tally */ summary_fill_in(&summary); @@ -273,7 +274,7 @@ mtp3_sum_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_) gtk_widget_show(file_box); /* filename */ - g_snprintf(string_buff, SUM_STR_MAX, "Name: %s", summary.filename); + g_snprintf(string_buff, SUM_STR_MAX, "Name: %s", ((summary.filename) ? summary.filename : "None")); add_string_to_box(string_buff, file_box); /* length */ @@ -281,7 +282,8 @@ mtp3_sum_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_) add_string_to_box(string_buff, file_box); /* format */ - g_snprintf(string_buff, SUM_STR_MAX, "Format: %s", wtap_file_type_string(summary.encap_type)); + file_type = wtap_file_type_string(summary.encap_type); + g_snprintf(string_buff, SUM_STR_MAX, "Format: %s", (file_type ? file_type : "N/A")); add_string_to_box(string_buff, file_box); if (summary.has_snap) { @@ -386,16 +388,31 @@ mtp3_sum_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_) g_snprintf(string_buff, SUM_STR_MAX, "Total MSUs: %u", tot_num_msus); add_string_to_box(string_buff, tot_box); - g_snprintf(string_buff, SUM_STR_MAX, "MSUs/second: %.2f", tot_num_msus/seconds); + if (seconds) { + g_snprintf(string_buff, SUM_STR_MAX, "MSUs/second: %.2f", tot_num_msus/seconds); + } + else { + g_snprintf(string_buff, SUM_STR_MAX, "MSUs/second: N/A"); + } add_string_to_box(string_buff, tot_box); g_snprintf(string_buff, SUM_STR_MAX, "Total Bytes: %.0f", tot_num_bytes); add_string_to_box(string_buff, tot_box); - g_snprintf(string_buff, SUM_STR_MAX, "Average Bytes/MSU: %.2f", tot_num_bytes/tot_num_msus); + if (tot_num_msus) { + g_snprintf(string_buff, SUM_STR_MAX, "Average Bytes/MSU: %.2f", tot_num_bytes/tot_num_msus); + } + else { + g_snprintf(string_buff, SUM_STR_MAX, "Average Bytes/MSU: N/A"); + } add_string_to_box(string_buff, tot_box); - g_snprintf(string_buff, SUM_STR_MAX, "Bytes/second: %.2f", tot_num_bytes/seconds); + if (seconds) { + g_snprintf(string_buff, SUM_STR_MAX, "Bytes/second: %.2f", tot_num_bytes/seconds); + } + else { + g_snprintf(string_buff, SUM_STR_MAX, "Bytes/second: N/A"); + } add_string_to_box(string_buff, tot_box); /* Button row. */ -- cgit v1.2.3