Patchwork [037/111] Correct invalid use of "const void *" with "const uint8_t *"

login
register
mail settings
Submitter Bryce Lanham
Date Aug. 17, 2011, 8:46 p.m.
Message ID <1313614076-28878-38-git-send-email-blanham@gmail.com>
Download mbox | patch
Permalink /patch/110351/
State New
Headers show

Comments

Bryce Lanham - Aug. 17, 2011, 8:46 p.m.
From: Laurent Vivier <laurent@vivier.eu>

When cpu-all.h is used with m68k-tester (an m68k testsuite),
the header is compiled with g++ and reports the following errors:

../qemu-m68k/cpu-all.h: In function ‘int lduw_be_p(const void*)’:
../qemu-m68k/cpu-all.h:414: error: invalid conversion from ‘const void*’ to ‘const uint8_t*’
../qemu-m68k/cpu-all.h: In function ‘int ldsw_be_p(const void*)’:
../qemu-m68k/cpu-all.h:429: error: invalid conversion from ‘const void*’ to ‘const uint8_t*’

This patch casts the variable to "const uint8_t*"

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 bswap.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Patch

diff --git a/bswap.h b/bswap.h
index f41bebe..13fd5cf 100644
--- a/bswap.h
+++ b/bswap.h
@@ -533,7 +533,7 @@  static inline int lduw_be_p(const void *ptr)
                   : "m" (*(uint16_t *)ptr));
     return val;
 #else
-    const uint8_t *b = ptr;
+    const uint8_t *b = (const uint8_t *)ptr;
     return ((b[0] << 8) | b[1]);
 #endif
 }
@@ -548,7 +548,7 @@  static inline int ldsw_be_p(const void *ptr)
                   : "m" (*(uint16_t *)ptr));
     return (int16_t)val;
 #else
-    const uint8_t *b = ptr;
+    const uint8_t *b = (const uint8_t *)ptr;
     return (int16_t)((b[0] << 8) | b[1]);
 #endif
 }
@@ -563,7 +563,7 @@  static inline int ldl_be_p(const void *ptr)
                   : "m" (*(uint32_t *)ptr));
     return val;
 #else
-    const uint8_t *b = ptr;
+    const uint8_t *b = (const uint8_t *)ptr;
     return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
 #endif
 }