Squelch more const warnings (and fix some memory leaks that found).
[obnox/wireshark/wip.git] / gtk / summary_dlg.c
index 2fd1317f6dd4a67be9bfed1601bc9c060be5f27b..079862ed9d3340d15d2244aa7bd2fcff1cb2433b 100644 (file)
@@ -97,7 +97,7 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
                 *main_vb, *bbox, *close_bt, *help_bt;
   GtkWidget     *table;
   GtkWidget     *list;
-  char          *titles[] = { "Traffic", "Captured", "Displayed" };
+  static const char *titles[] = { "Traffic", "Captured", "Displayed" };
 
   gchar         string_buff[SUM_STR_MAX];
   gchar         string_buff2[SUM_STR_MAX];
@@ -306,13 +306,15 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
   /* Packet size */
   if (summary.packet_count > 0){
     g_snprintf(string_buff, SUM_STR_MAX, "%.3f bytes",
-      (float)summary.bytes/summary.packet_count);
+      /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
+      (float) (gint64) (summary.bytes/summary.packet_count) );
   } else {
     strcpy(string_buff, "");
   }
   if (summary.dfilter && summary.filtered_count > 0){
     g_snprintf(string_buff2, SUM_STR_MAX, "%.3f bytes",
-          (float) summary.filtered_bytes/summary.filtered_count);
+          /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
+          (float) (gint64) summary.filtered_bytes/summary.filtered_count);
   } else {
     strcpy(string_buff2, "");
   }
@@ -329,12 +331,14 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
 
   /* Bytes per second */
   if (seconds > 0){
-    g_snprintf(string_buff, SUM_STR_MAX, "%.3f", summary.bytes/seconds);
+    /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
+    g_snprintf(string_buff, SUM_STR_MAX, "%.3f", ((gint64) summary.bytes)/seconds );
   } else {
     strcpy(string_buff, "");
   }
   if (summary.dfilter && disp_seconds > 0){
-    g_snprintf(string_buff2, SUM_STR_MAX, "%.3f", summary.filtered_bytes/disp_seconds);
+    /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
+    g_snprintf(string_buff2, SUM_STR_MAX, "%.3f", ((gint64) summary.filtered_bytes)/disp_seconds );
   } else {
     strcpy(string_buff2, "");
   }
@@ -342,13 +346,15 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
 
   /* MBit per second */
   if (seconds > 0){
-    g_snprintf(string_buff, SUM_STR_MAX, "%.3f", summary.bytes * 8.0 / (seconds * 1000.0 * 1000.0));
+    /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
+    g_snprintf(string_buff, SUM_STR_MAX, "%.3f", ((gint64) summary.bytes) * 8.0 / (seconds * 1000.0 * 1000.0));
   } else {
     strcpy(string_buff, "");
   }
   if (summary.dfilter && disp_seconds > 0){
     g_snprintf(string_buff2, SUM_STR_MAX, "%.3f", 
-          summary.filtered_bytes * 8.0 / (disp_seconds * 1000.0 * 1000.0));
+          /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
+          ((gint64) summary.filtered_bytes) * 8.0 / (disp_seconds * 1000.0 * 1000.0));
   } else {
     strcpy(string_buff2, "");
   }