cppcheck warnings fixed.
[m6w6/libmemcached] / clients / ms_stats.c
index 7fad7fb8e0aeb1f24a7fbf67ae80284811fab4a8..8d62a5aaa1ebf1649171fa8955c5d990c0d16592 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "config.h"
 
+#include <inttypes.h>
 #include "ms_stats.h"
 
 #define array_size(x)    (sizeof(x) / sizeof((x)[0]))
@@ -191,7 +192,7 @@ void ms_dump_stats(ms_stat_t *stat)
     {
       printf("\n      %2d:", (int)i);
     }
-    printf("   %6ld", stat->dist[i]);
+    printf("   %6" PRIu64 , stat->dist[i]);
   }
 
   printf("\n\n");
@@ -218,10 +219,6 @@ void ms_dump_format_stats(ms_stat_t *stat,
   double global_std= 0;
   double global_log= 0;
 
-  uint64_t diff_time= 0;
-  uint64_t diff_events= 0;
-  double diff_squares= 0;
-  double diff_log_product= 0;
   double period_average= 0;
   uint64_t period_tps= 0;
   double period_rate= 0;
@@ -240,17 +237,17 @@ void ms_dump_format_stats(ms_stat_t *stat,
                     * global_average) / (double)(events - 1));
   global_log= exp(stat->log_product / (double)events);
 
-  diff_time= stat->total_time - stat->pre_total_time;
-  diff_events= events - stat->pre_events;
+  uint64_t diff_time= stat->total_time - stat->pre_total_time;
+  uint64_t diff_events= events - stat->pre_events;
   if (diff_events >= 1)
   {
     period_average= (double)(diff_time / diff_events);
     period_tps= diff_events / (uint64_t)freq;
     period_rate= (double)diff_events * obj_size / 1024 / 1024 / freq;
-    diff_squares= (double)stat->squares - (double)stat->pre_squares;
+    double diff_squares= (double)stat->squares - (double)stat->pre_squares;
     period_std= sqrt((diff_squares - (double)diff_events * period_average
                       * period_average) / (double)(diff_events - 1));
-    diff_log_product= stat->log_product - stat->pre_log_product;
+    double diff_log_product= stat->log_product - stat->pre_log_product;
     period_log= exp(diff_log_product / (double)diff_events);
   }