From 155eb9aa09249874b4ff49e94c58595ad82d3abb Mon Sep 17 00:00:00 2001 From: Avishay Traeger Date: Wed, 6 Apr 2011 10:45:36 +0300 Subject: Fix integer overflow in block migration bandwidth calculation block_mig_state.reads is an int, and multiplying by BLOCK_SIZE yielded a negative number, resulting in a negative bandwidth (running on a 32-bit machine). Change order to avoid. Signed-off-by: Avishay Traeger Signed-off-by: Kevin Wolf --- block-migration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'block-migration.c') diff --git a/block-migration.c b/block-migration.c index 8218bac..576e55a 100644 --- a/block-migration.c +++ b/block-migration.c @@ -140,7 +140,7 @@ static inline void add_avg_read_time(int64_t time) static inline long double compute_read_bwidth(void) { assert(block_mig_state.total_time != 0); - return (block_mig_state.reads * BLOCK_SIZE)/ block_mig_state.total_time; + return (block_mig_state.reads / block_mig_state.total_time) * BLOCK_SIZE; } static int bmds_aio_inflight(BlkMigDevState *bmds, int64_t sector) -- cgit v1.1