Hello,
This is a patch for MAP operation statistics in gsm_map_stat.c.
Add a test to avoid divide by zero during stat. display.
Use new variable j, instead of i, already used in the loop.
Florent
<<
Index: gtk/gsm_map_stat.c
===================================================================
--- gtk/gsm_map_stat.c (revision 17356)
+++ gtk/gsm_map_stat.c (working copy)
@@ -168,7 +168,9 @@
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 @@
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 @@
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 @@
GtkWidget *w _U_,
gpointer d _U_)
{
- int i;
+ int i,j;
/*
@@ -423,9 +429,9 @@
/*
* 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; j++)
{
- dlg.entries[i] = g_strdup("0");
+ dlg.entries[j] = g_strdup("0");
}
gtk_clist_insert(GTK_CLIST(dlg.table), i, dlg.entries);
>>