Skip to contentSkip to conversation

migration: fix xbzrle encoding rate calculation

PATCH In review Wei Wang 3 participants 4 messages Jun 8, 2020 – Jun 10, 2020

lore
Share & tools
lore

Wei Wang

author
#0 lore raw

PATCH 1/1 migration: fix xbzrle encoding rate calculation

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.

---
 migration/ram.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
migration/ram.c +1 -3
index 41cc530..069b6e3 100644
@@ -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;
         }
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Wei Wang

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.

---
 migration/ram.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

r~

#3 lore raw
Quoted 5 lines · * Richard Henderson ([email protected]) wrote:
Quoted 4 lines · Wei Wang

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.

Quoted 8 lines
Quoted 6 lines
---
 migration/ram.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Queuing to a clang 10 fixes branch.

Thanks

Dave

Quoted 4 lines

r~

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK