From 92271402177bb02930113a853f64952d8689b0c0 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Wed, 17 Jun 2020 13:13:05 -0700 Subject: migration: fix xbzrle encoding rate calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's reported an error of implicit conversion from "unsigned long" to "double" when compiling with Clang 10. Simply make the encoding rate 0 when the encoded_size is 0. Fixes: e460a4b1a4 Reviewed-by: Alex Bennée Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Richard Henderson Reported-by: Richard Henderson Signed-off-by: Wei Wang Signed-off-by: Richard Henderson Message-id: 20200617201309.1640952-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- migration/ram.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'migration') diff --git a/migration/ram.c b/migration/ram.c index 41cc530..069b6e3 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -913,10 +913,8 @@ static void migration_update_rates(RAMState *rs, int64_t end_time) unencoded_size = (xbzrle_counters.pages - rs->xbzrle_pages_prev) * TARGET_PAGE_SIZE; encoded_size = xbzrle_counters.bytes - rs->xbzrle_bytes_prev; - if (xbzrle_counters.pages == rs->xbzrle_pages_prev) { + if (xbzrle_counters.pages == rs->xbzrle_pages_prev || !encoded_size) { xbzrle_counters.encoding_rate = 0; - } else if (!encoded_size) { - xbzrle_counters.encoding_rate = UINT64_MAX; } else { xbzrle_counters.encoding_rate = unencoded_size / encoded_size; } -- cgit v1.1