[Spice-devel] [PATCH 3/7] spice-ppc: Fixing endianess for channel messages

Erlon Cruz erlon.cruz at br.flextronics.com
Tue Aug 7 11:39:14 PDT 2012


Signed-off-by: Erlon R. Cruz <erlon.cruz at br.flextronics.com>
Signed-off-by: Fabiano Fidêncio <Fabiano.Fidêncio at fit-tecnologia.org.br>
Signed-off-by: Rafael F. Santos <Rafael.Santos at fit-tecnologia.org.br>
---
 server/red_channel.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/server/red_channel.c b/server/red_channel.c
index 2a7acbf..f376265 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -29,6 +29,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
+#include <endian.h>
 
 #include "common/generated_server_marshallers.h"
 #include "common/ring.h"
@@ -84,47 +85,47 @@ static void red_channel_client_unref(RedChannelClient *rcc);
 
 static uint32_t full_header_get_msg_size(SpiceDataHeaderOpaque *header)
 {
-    return ((SpiceDataHeader *)header->data)->size;
+    return le32toh(((SpiceDataHeader *)header->data)->size);
 }
 
 static uint32_t mini_header_get_msg_size(SpiceDataHeaderOpaque *header)
 {
-    return ((SpiceMiniDataHeader *)header->data)->size;
+    return le32toh(((SpiceMiniDataHeader *)header->data)->size);
 }
 
 static uint16_t full_header_get_msg_type(SpiceDataHeaderOpaque *header)
 {
-    return ((SpiceDataHeader *)header->data)->type;
+    return le16toh(((SpiceDataHeader *)header->data)->type);
 }
 
 static uint16_t mini_header_get_msg_type(SpiceDataHeaderOpaque *header)
 {
-    return ((SpiceMiniDataHeader *)header->data)->type;
+    return le16toh(((SpiceMiniDataHeader *)header->data)->type);
 }
 
 static void full_header_set_msg_type(SpiceDataHeaderOpaque *header, uint16_t type)
 {
-    ((SpiceDataHeader *)header->data)->type = type;
+    ((SpiceDataHeader *)header->data)->type = htole16(type);
 }
 
 static void mini_header_set_msg_type(SpiceDataHeaderOpaque *header, uint16_t type)
 {
-    ((SpiceMiniDataHeader *)header->data)->type = type;
+    ((SpiceMiniDataHeader *)header->data)->type = htole16(type);
 }
 
 static void full_header_set_msg_size(SpiceDataHeaderOpaque *header, uint32_t size)
 {
-    ((SpiceDataHeader *)header->data)->size = size;
+    ((SpiceDataHeader *)header->data)->size = htole32(size);
 }
 
 static void mini_header_set_msg_size(SpiceDataHeaderOpaque *header, uint32_t size)
 {
-    ((SpiceMiniDataHeader *)header->data)->size = size;
+    ((SpiceMiniDataHeader *)header->data)->size = htole32(size);
 }
 
 static void full_header_set_msg_serial(SpiceDataHeaderOpaque *header, uint64_t serial)
 {
-    ((SpiceDataHeader *)header->data)->serial = serial;
+    ((SpiceDataHeader *)header->data)->serial = htole64(serial);
 }
 
 static void mini_header_set_msg_serial(SpiceDataHeaderOpaque *header, uint64_t serial)
@@ -134,7 +135,7 @@ static void mini_header_set_msg_serial(SpiceDataHeaderOpaque *header, uint64_t s
 
 static void full_header_set_msg_sub_list(SpiceDataHeaderOpaque *header, uint32_t sub_list)
 {
-    ((SpiceDataHeader *)header->data)->sub_list = sub_list;
+    ((SpiceDataHeader *)header->data)->sub_list = htole32(sub_list);
 }
 
 static void mini_header_set_msg_sub_list(SpiceDataHeaderOpaque *header, uint32_t sub_list)
-- 
1.7.4.1



More information about the Spice-devel mailing list