Skip to contentSkip to conversation

xbzrle: fix compilation on ppc32

PATCH In review Alexander Graf 2 participants 2 messages Aug 14, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xbzrle: fix compilation on ppc32

When compiling the xbzrle code on my ppc32 user space, I hit the following gcc compiler warning (treated as an error):

cc1: warnings being treated as errors
savevm.c: In function ‘xbzrle_encode_buffer’:
savevm.c:2476: error: overflow in implicit constant conversion

Fix this by making the cast explicit, rather than implicit.

---
 savevm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
savevm.c +1 -1
index 0ea10c9..9ab4d83 100644
@@ -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.6.0.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Alexander Graf

When compiling the xbzrle code on my ppc32 user space, I hit the following gcc compiler warning (treated as an error):

cc1: warnings being treated as errors
savevm.c: In function ‘xbzrle_encode_buffer’:
savevm.c:2476: error: overflow in implicit constant conversion

Quoted 6 lines

Fix this by making the cast explicit, rather than implicit.

---
 savevm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

savevm.c int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen, · line 2476

Quoted 11 lines
savevm.c +1 -1
index 0ea10c9..9ab4d83 100644
@@ -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;

What a picky compiler - too bad it can't just read the comment above that said we are okay with truncation :)

Signature · 2 lines
Eric Blake   [email protected]    +1-919-301-3266
Libvirt virtualization library http://libvirt.org