changeset 224:af22394620e9

fix endian targeting on big endian arch...
author Louis Opter <kalessin@kalessin.fr>
date Sat, 08 Aug 2015 01:13:52 -0700
parents ff35ea8532ca
children b9be1fdb2f6b
files fix_targeting_on_big_endian_architectures.patch series
diffstat 2 files changed, 51 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fix_targeting_on_big_endian_architectures.patch	Sat Aug 08 01:13:52 2015 -0700
@@ -0,0 +1,50 @@
+# HG changeset patch
+# Parent  19383f32944eded3babc54cd9a7fc623e8f74462
+Fix tag targeting on big endian platforms
+
+:\
+
+diff --git a/lifx/wire_proto.c b/lifx/wire_proto.c
+--- a/lifx/wire_proto.c
++++ b/lifx/wire_proto.c
+@@ -246,7 +246,7 @@
+     }
+     if (flags & LGTD_LIFX_TAGGED) {
+         hdr->protocol |= LGTD_LIFX_PROTOCOL_TAGGED;
+-        htole64(hdr->target.tags);
++        hdr->target.tags = htole64(hdr->target.tags);
+     }
+     if (flags & LGTD_LIFX_ACK_REQUIRED) {
+         hdr->flags |= LGTD_LIFX_FLAG_ACK_REQUIRED;
+@@ -267,8 +267,13 @@
+     assert(hdr);
+ 
+     hdr->size = le16toh(hdr->size);
+-    hdr->protocol = le16toh(hdr->protocol & LGTD_LIFX_PROTOCOL_VERSION_MASK)
+-        | (hdr->protocol & LGTD_LIFX_PROTOCOL_FLAGS_MASK);
++    hdr->protocol = (
++        le16toh(hdr->protocol & LGTD_LIFX_PROTOCOL_VERSION_MASK)
++        | (hdr->protocol & LGTD_LIFX_PROTOCOL_FLAGS_MASK)
++    );
++    if (hdr->protocol & LGTD_LIFX_PROTOCOL_TAGGED) {
++        hdr->target.tags = le64toh(hdr->target.tags);
++    }
+     hdr->at_time = le64toh(hdr->at_time);
+     hdr->packet_type = le16toh(hdr->packet_type);
+ }
+diff --git a/tests/lifx/wire_proto/test_wire_proto_encode_decode_header.c b/tests/lifx/wire_proto/test_wire_proto_encode_decode_header.c
+--- a/tests/lifx/wire_proto/test_wire_proto_encode_decode_header.c
++++ b/tests/lifx/wire_proto/test_wire_proto_encode_decode_header.c
+@@ -20,10 +20,10 @@
+     if (le16toh(hdr.size) != 42) {
+         lgtd_errx(1, "size = %hu (expected = 42)", le16toh(hdr.size));
+     }
+-    if (le64toh(hdr.target.tags != 0xbad)) {
++    if (le64toh(hdr.target.tags) != 0xbad) {
+         lgtd_errx(
+             1, "tags = %#jx (expected = 0xbad)",
+-            (uintmax_t)le16toh(hdr.target.tags)
++            (uintmax_t)le64toh(hdr.target.tags)
+         );
+     }
+     if (le16toh(hdr.packet_type) != LGTD_LIFX_ECHO_REQUEST) {
--- a/series	Fri Aug 07 00:17:50 2015 -0700
+++ b/series	Sat Aug 08 01:13:52 2015 -0700
@@ -11,3 +11,4 @@
 fix_unused_unused_attribute.patch
 properly_encode_packets_payload.patch #-skip
 relax_timings.patch
+fix_targeting_on_big_endian_architectures.patch