savevm.c: Fix compilation error on 32bit host.
PATCH 1/1 savevm.c: Fix compilation error on 32bit host.
Casting of 0x0101010101010101ULL to long will truncate it to 32 bits on 32bit hosts, and won't truncate on 64bit hosts.
--- savevm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
savevm.c +1 -1
@@ -2473,7 +2473,7 @@ int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,/* word at a time for speed, use of 32-bit long okay */ if (!res) {/* truncation to 32-bit long okay */ -long mask =0x0101010101010101ULL ; +long mask = (long )0x0101010101010101ULL ;while (i < slen) { xor = *(long *)(old_buf + i) ^ *(long *)(new_buf + i);if ((xor - mask) & ~xor & (mask <<7 )) {
Signature · 1 line
1.7.9.5
Quoted 4 lines · Evgeny Voevodin
Casting of
0x0101010101010101ULLto long will truncate it to 32 bits on 32bit hosts, and won't truncate on 64bit hosts.Signed-off-by Evgeny Voevodin <[email protected]>
Dup of http://patchwork.ozlabs.org/patch/177217/ I'm afraid.
-- PMM
Quoted 11 lines · Peter Maydell
Quoted 4 lines · Evgeny Voevodin
Casting of
0x0101010101010101ULLto long will truncate it to 32 bits on 32bit hosts, and won't truncate on 64bit hosts.Signed-off-by Evgeny Voevodin <[email protected]>Dup of http://patchwork.ozlabs.org/patch/177217/ I'm afraid.
-- PMM
Don't be afraid, it's true. I didn't see it in the mailing list and didn't know that the bug is already fixed there.
Signature · 5 lines
Kind regards, Evgeny Voevodin, Leading Software Engineer, ASWG, Moscow R&D center, Samsung Electronics e-mail: [email protected]
Quoted 13 lines · Evgeny Voevodin
Casting of
0x0101010101010101ULLto long will truncate it to 32 bits on 32bit hosts, and won't truncate on 64bit hosts.Signed-off-by Evgeny Voevodin <[email protected]>--- savevm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)savevm.c +0
-0
savevm.c int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen, · line 2479
Quoted 8 lines
savevm.c +1
-1@@ -2473,7 +2473,7 @@ int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,/* word at a time for speed, use of 32-bit long okay */ if (!res) {/* truncation to 32-bit long okay */ -long mask =0x0101010101010101ULL ; +long mask = (long )0x0101010101010101ULL ;while (i < slen) { xor = *(long *)(old_buf + i) ^ *(long *)(new_buf + i);if ((xor - mask) & ~xor & (mask <<7 )) {
Um, how it is ugly... Can't we use unsigned types for all this stuff? Including slen too - the function parameter...
Thanks,
/mjt