aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/mtp3_summary.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2009-03-17 19:37:10 +0000
committerGuy Harris <guy@alum.mit.edu>2009-03-17 19:37:10 +0000
commit5ccab9cbcb9ad7b5fc481bbb41941a3e417546a3 (patch)
tree0929464a387d19ed092285a1ec3f049aba11a752 /gtk/mtp3_summary.c
parenta993847667e564ed9cef847b700ab01a83d45a60 (diff)
Clean up indentation.
Cast the num_msus and num_bytes values to double before dividing them by the appropriate divisor, to make sure the division is done in floating point; that's only necessary in one case (when dividing by an integer), but we do it in all cases for regularity. g_strdup_printf() g_mallocs the string; use g_strdup() for the zero-divisor case, so that the string is g_mallocated in all cases. Note in a comment that they need to be freed. Make the array to which the strings in question are allocated arrays of "char *" rather than "const char *", to catch cases where a constant string is assigned to them. svn path=/trunk/; revision=27760
Diffstat (limited to 'gtk/mtp3_summary.c')
-rw-r--r--gtk/mtp3_summary.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/gtk/mtp3_summary.c b/gtk/mtp3_summary.c
index 039db0dd72..7d90594ce8 100644
--- a/gtk/mtp3_summary.c
+++ b/gtk/mtp3_summary.c
@@ -221,52 +221,55 @@ mtp3_sum_draw(
int *tot_num_msus_p,
double *tot_num_bytes_p)
{
- const char *entries[N_COLUMN];
+ char *entries[N_COLUMN];
int i, j;
int num_msus;
int num_bytes;
GtkListStore *list_store = NULL;
- GtkTreeIter iter;
+ GtkTreeIter iter;
*tot_num_msus_p = 0;
*tot_num_bytes_p = 0;
- list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (table))); /* Get store */
+ list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (table))); /* Get store */
for (i=0; i < MTP3_NUM_SI_CODE; i++)
{
- j = 0;
- num_msus = 0;
- num_bytes = 0;
+ j = 0;
+ num_msus = 0;
+ num_bytes = 0;
- while (j < mtp3_num_used)
- {
- num_msus += mtp3_stat[j].si_code[i].num_msus;
- num_bytes += mtp3_stat[j].si_code[i].size;
+ while (j < mtp3_num_used)
+ {
+ num_msus += mtp3_stat[j].si_code[i].num_msus;
+ num_bytes += mtp3_stat[j].si_code[i].size;
- j++;
- }
+ j++;
+ }
- *tot_num_msus_p += num_msus;
- *tot_num_bytes_p += num_bytes;
+ *tot_num_msus_p += num_msus;
+ *tot_num_bytes_p += num_bytes;
- entries[2] = (seconds) ? g_strdup_printf("%.2f", num_msus/seconds) : "N/A";
- entries[4] = (num_msus) ? g_strdup_printf("%.2f", num_bytes/num_msus) : "N/A";
- entries[5] = (seconds) ? g_strdup_printf("%.2f", num_bytes/seconds) : "N/A";
+ /*
+ * XXX - when do these get freed?
+ */
+ entries[2] = (seconds) ? g_strdup_printf("%.2f", (double)num_msus/seconds) : g_strdup("N/A");
+ entries[4] = (num_msus) ? g_strdup_printf("%.2f", (double)num_bytes/num_msus) : g_strdup("N/A");
+ entries[5] = (seconds) ? g_strdup_printf("%.2f", (double)num_bytes/seconds) : g_strdup("N/A");
#if GTK_CHECK_VERSION(2,6,0)
- gtk_list_store_insert_with_values( list_store , &iter, G_MAXINT,
+ gtk_list_store_insert_with_values( list_store , &iter, G_MAXINT,
#else
- gtk_list_store_append (list_store, &iter);
- gtk_list_store_set (list_store, &iter,
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter,
#endif
- SI_COLUMN, mtp3_service_indicator_code_short_vals[i].strptr,
- NUM_MSUS_COLUMN, num_msus,
- NUM_MSUS_SEC_COLUMN, entries[2],
- NUM_BYTES_COLUMN, num_bytes,
- NUM_BYTES_MSU_COLUMN, entries[4],
- NUM_BYTES_SEC_COLUMN, entries[5],
- -1);
+ SI_COLUMN, mtp3_service_indicator_code_short_vals[i].strptr,
+ NUM_MSUS_COLUMN, num_msus,
+ NUM_MSUS_SEC_COLUMN, entries[2],
+ NUM_BYTES_COLUMN, num_bytes,
+ NUM_BYTES_MSU_COLUMN, entries[4],
+ NUM_BYTES_SEC_COLUMN, entries[5],
+ -1);
}
}