Fix some Dereference of null pointer Warning found by Clang
[obnox/wireshark/wip.git] / timestats.c
index ed5cd5a86fbc0a97f048fb1d4eb4b9548f4df01c..67bda7a73fdc63aea66fce8a200cbf12733a85a5 100644 (file)
@@ -4,8 +4,8 @@
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include "timestats.h"
 
 /* Initialize a timestat_t struct */
@@ -30,12 +34,12 @@ void
 time_stat_init(timestat_t *stats)
 {
        stats->num = 0;
-       stats->min.secs = 0;
-       stats->min.nsecs = 0;
-       stats->max.secs = 0;
-       stats->max.nsecs = 0;
-       stats->tot.secs = 0;
-       stats->tot.nsecs = 0;
+       stats->min_num = 0;
+       stats->max_num = 0;
+       nstime_set_zero(&stats->min);
+       nstime_set_zero(&stats->max);
+       nstime_set_zero(&stats->tot);
+       stats->variance = 0.0;
 }
 
 /* Update a timestat_t struct with a new sample */
@@ -63,7 +67,7 @@ time_stat_update(timestat_t *stats, const nstime_t *delta, packet_info *pinfo)
                stats->max_num=pinfo->fd->num;
        }
 
-       addtime(&stats->tot, delta);
+       nstime_add(&stats->tot, delta);
 
        stats->num++;
 }