[PATCH xserver 2/4] x86emu: Fix type conversion warnings on x86_64 with DEBUG

Lyude Paul lyude at redhat.com
Fri Oct 13 19:44:30 UTC 2017


Warnings come from the fact that PRIx32 is not used for printing 32 bit
values instead of "%lx", and "%lx" evaluates to a 64 bit long on 64 bit
systems while PRIx32 always evaluates to the right type for the
respective arch.

Signed-off-by: Lyude Paul <lyude at redhat.com>
---
 hw/xfree86/x86emu/sys.c          | 12 ++++++------
 hw/xfree86/x86emu/x86emu/types.h |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/hw/xfree86/x86emu/sys.c b/hw/xfree86/x86emu/sys.c
index 5eba35856..ccce540e7 100644
--- a/hw/xfree86/x86emu/sys.c
+++ b/hw/xfree86/x86emu/sys.c
@@ -191,7 +191,7 @@ rdb(u32 addr)
     u8 val;
 
     if (addr > M.mem_size - 1) {
-        DB(printk("mem_read: address %#lx out of range!\n", addr);
+        DB(printk("mem_read: address %#" PRIx32 " out of range!\n", addr);
             )
             HALT_SYS();
     }
@@ -217,7 +217,7 @@ rdw(u32 addr)
     u16 val = 0;
 
     if (addr > M.mem_size - 2) {
-        DB(printk("mem_read: address %#lx out of range!\n", addr);
+        DB(printk("mem_read: address %#" PRIx32 " out of range!\n", addr);
             )
             HALT_SYS();
     }
@@ -249,7 +249,7 @@ rdl(u32 addr)
     u32 val = 0;
 
     if (addr > M.mem_size - 4) {
-        DB(printk("mem_read: address %#lx out of range!\n", addr);
+        DB(printk("mem_read: address %#" PRIx32 " out of range!\n", addr);
             )
             HALT_SYS();
     }
@@ -282,7 +282,7 @@ wrb(u32 addr, u8 val)
     DB(if (DEBUG_MEM_TRACE())
        printk("%#08x 1 <- %#x\n", addr, val);)
         if (addr > M.mem_size - 1) {
-            DB(printk("mem_write: address %#lx out of range!\n", addr);
+            DB(printk("mem_write: address %#" PRIx32 " out of range!\n",addr);
                 )
                 HALT_SYS();
         }
@@ -303,7 +303,7 @@ wrw(u32 addr, u16 val)
     DB(if (DEBUG_MEM_TRACE())
        printk("%#08x 2 <- %#x\n", addr, val);)
         if (addr > M.mem_size - 2) {
-            DB(printk("mem_write: address %#lx out of range!\n", addr);
+            DB(printk("mem_write: address %#" PRIx32 " out of range!\n",addr);
                 )
                 HALT_SYS();
         }
@@ -331,7 +331,7 @@ wrl(u32 addr, u32 val)
     DB(if (DEBUG_MEM_TRACE())
        printk("%#08x 4 <- %#x\n", addr, val);)
         if (addr > M.mem_size - 4) {
-            DB(printk("mem_write: address %#lx out of range!\n", addr);
+            DB(printk("mem_write: address %#" PRIx32 " out of range!\n",addr);
                 )
                 HALT_SYS();
         }
diff --git a/hw/xfree86/x86emu/x86emu/types.h b/hw/xfree86/x86emu/x86emu/types.h
index 5a6ef01f8..0559bc089 100644
--- a/hw/xfree86/x86emu/x86emu/types.h
+++ b/hw/xfree86/x86emu/x86emu/types.h
@@ -61,6 +61,7 @@
 /*---------------------- Macros and type definitions ----------------------*/
 
 #include <stdint.h>
+#include <inttypes.h>
 
 typedef uint8_t u8;
 typedef uint16_t u16;
-- 
2.13.6



More information about the xorg-devel mailing list