qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Fix console_write_ch on 64-bit big-endian hosts


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH] Fix console_write_ch on 64-bit big-endian hosts
Date: Wed, 2 Jun 2010 13:58:53 -0500

Currently, console_ch_t is defined as an unsigned long.  However, immediately
after it's definition, we treat it as a uint32_t *.  This will work on a little
endian system because of the way bits are layed out but will fail miserably
on big endian hosts.

This patch fixes the code to do the correct thing.  This addresses
https://bugs.launchpad.net/qemu/+bug/568614

Reported-by: Devin J. Pohly
Signed-off-by: Anthony Liguori <address@hidden>

diff --git a/console.h b/console.h
index cac959f..ddd1bbf 100644
--- a/console.h
+++ b/console.h
@@ -326,9 +326,11 @@ static inline int ds_get_bytes_per_pixel(DisplayState *ds)
 typedef unsigned long console_ch_t;
 static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
 {
+    uint32_t p;
     if (!(ch & 0xff))
         ch |= ' ';
-    cpu_to_le32wu((uint32_t *) dest, ch);
+    cpu_to_le32wu(&p, ch);
+    *dest = p;
 }
 
 typedef void (*vga_hw_update_ptr)(void *);
-- 
1.7.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]