[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] xenbaked: properly use time_t in dump_stats()
commit 722a61dbb5010507693593243dbba311d4e9c0b5 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Mon Aug 22 12:10:00 2022 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon Aug 22 12:10:00 2022 +0200 xenbaked: properly use time_t in dump_stats() "int" is not a suitable type to convert time()'s return value to. Avoid casts and other extra fiddling by using difftime(), on the assumption that the overhead of using "double" doesn't matter here. Coverity ID: 1509374 Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> --- tools/xenmon/xenbaked.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c index 7591de7c60..4dddbd20e2 100644 --- a/tools/xenmon/xenbaked.c +++ b/tools/xenmon/xenbaked.c @@ -230,11 +230,7 @@ static void check_gotten_sum(void) static void dump_stats(void) { stat_map_t *smt = stat_map; - time_t end_time, run_time; - - time(&end_time); - - run_time = end_time - start_time; + double run_time = difftime(time(NULL), start_time); printf("Event counts:\n"); while (smt->text != NULL) { @@ -242,13 +238,11 @@ static void dump_stats(void) smt++; } - printf("processed %d total records in %d seconds (%ld per second)\n", - rec_count, (int)run_time, - run_time ? (long)(rec_count/run_time) : 0L); + printf("processed %d total records in %.0f seconds (%.0f per second)\n", + rec_count, run_time, run_time ? rec_count / run_time : 0); - printf("woke up %d times in %d seconds (%ld per second)\n", - wakeups, (int) run_time, - run_time ? (long)(wakeups/run_time) : 0L); + printf("woke up %d times in %.0f seconds (%.0f per second)\n", + wakeups, run_time, run_time ? wakeups / run_time : 0); check_gotten_sum(); } -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |