Commit cf1a24e0 authored by Joanne Hugé's avatar Joanne Hugé

Fix integer overflow

parent 31441586
...@@ -252,8 +252,11 @@ static void print_histograms() { ...@@ -252,8 +252,11 @@ static void print_histograms() {
int interval = param->interval / 1000; int interval = param->interval / 1000;
uint64_t duration = interval * param->stats.nb_cycles; uint64_t duration = interval * param->stats.nb_cycles;
int duration_hour = duration / (1000000l * 3600); int duration_hour = duration / 1000000;
int duration_minutes = duration / (1000000l * 60) - (duration_hour * 60); duration_hour /= 3600;
int duration_minutes = duration / 1000000l;
duration_minutes /= 60;
duration_minutes -= duration_hour * 60;
printf("], "); printf("], ");
printf("\"props_type\": \"histogram\", \"metadata\": {\"i\": \"%dus\", \"duration\": \"%dh%d\"}}\n", interval, duration_hour, duration_minutes); printf("\"props_type\": \"histogram\", \"metadata\": {\"i\": \"%dus\", \"duration\": \"%dh%d\"}}\n", interval, duration_hour, duration_minutes);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment