aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2006-02-27 08:33:29 +0000
committerAnders Broman <anders.broman@ericsson.com>2006-02-27 08:33:29 +0000
commit983d800af7565dd60bea637bd84eb8a83ea93f7c (patch)
tree723036573e6ea88081a44813d651c5f1e193ebf5 /gtk
parent8b84860a235a83653800f62de76b6d32da94a14e (diff)
From: Florent Drouin:
Add a test to avoid divide by zero during stat. display. Use new variable j, instead of i, already used in the loop. svn path=/trunk/; revision=17416
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gsm_map_stat.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/gtk/gsm_map_stat.c b/gtk/gsm_map_stat.c
index 691cf57f65..31f2a92297 100644
--- a/gtk/gsm_map_stat.c
+++ b/gtk/gsm_map_stat.c
@@ -168,7 +168,9 @@ gsm_map_stat_draw(
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 3, strp);
g_free(strp);
- strp = g_strdup_printf("%.2f", stat_p->size[i]/stat_p->opr_code[i]);
+ if (stat_p->opr_code[i] >0)
+ strp = g_strdup_printf("%.2f",stat_p->size[i]/stat_p->opr_code[i]);
+ else strp=g_strdup_printf("--");
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 4, strp);
g_free(strp);
@@ -180,7 +182,9 @@ gsm_map_stat_draw(
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 6, strp);
g_free(strp);
- strp = g_strdup_printf("%.2f", stat_p->size_rr[i]/stat_p->opr_code_rr[i]);
+ if (stat_p->opr_code_rr[i]>0)
+ strp = g_strdup_printf("%.2f",stat_p->size_rr[i]/stat_p->opr_code_rr[i]);
+ else strp=g_strdup_printf("--");
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 7, strp);
g_free(strp);
@@ -188,8 +192,10 @@ gsm_map_stat_draw(
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 8, strp);
g_free(strp);
- strp = g_strdup_printf("%.2f",
- (stat_p->size[i] + stat_p->size_rr[i])/(stat_p->opr_code[i] + stat_p->opr_code_rr[i]));
+ if ((stat_p->opr_code[i] + stat_p->opr_code_rr[i])>0)
+ strp = g_strdup_printf("%.2f",
+ (stat_p->size[i] +stat_p->size_rr[i])/(stat_p->opr_code[i] + stat_p->opr_code_rr[i]));
+ else strp=g_strdup_printf("--");
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 9, strp);
g_free(strp);
@@ -398,7 +404,7 @@ gsm_map_stat_gtk_cb(
GtkWidget *w _U_,
gpointer d _U_)
{
- int i;
+ int i,j;
/*
@@ -423,9 +429,9 @@ gsm_map_stat_gtk_cb(
/*
* set the rest of the columns
*/
- for (i = 2; i < GSM_MAP_INIT_TABLE_NUM_COLUMNS; i++)
+ for (j = 2; j < GSM_MAP_INIT_TABLE_NUM_COLUMNS; i++)
{
- dlg.entries[i] = g_strdup("0");
+ dlg.entries[j] = g_strdup("0");
}
gtk_clist_insert(GTK_CLIST(dlg.table), i, dlg.entries);