This commit uses the C99 ULL suffix to tell the compiler to treat the
constant as 64-bits, and also masks portions of the uint64_t argument to
the htons() calls to avoid compiler errors.

Signed-off-by: Aaron Conole <[email protected]>
---
 lib/packets.h   | 4 ++--
 tests/test-aa.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/packets.h b/lib/packets.h
index fd235dc..a4f6383 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -230,8 +230,8 @@ static inline uint64_t eth_addr_vlan_to_uint64(const struct 
eth_addr ea,
 static inline void eth_addr_from_uint64(uint64_t x, struct eth_addr *ea)
 {
     ea->be16[0] = htons(x >> 32);
-    ea->be16[1] = htons(x >> 16);
-    ea->be16[2] = htons(x);
+    ea->be16[1] = htons((x & 0xFFFF0000) >> 16);
+    ea->be16[2] = htons(x & 0xFFFF);
 }
 
 static inline struct eth_addr eth_addr_invert(const struct eth_addr src)
diff --git a/tests/test-aa.c b/tests/test-aa.c
index 0b0e256..2da572d 100644
--- a/tests/test-aa.c
+++ b/tests/test-aa.c
@@ -153,7 +153,7 @@ test_aa_send(void)
     hardware.h_lport.p_element.type =
         LLDP_TLV_AA_ELEM_TYPE_CLIENT_VIRTUAL_SWITCH;
     hardware.h_lport.p_element.mgmt_vlan = 0xCDC;
-    eth_addr_from_uint64(0x010203040506,
+    eth_addr_from_uint64(0x010203040506ULL,
                          &hardware.h_lport.p_element.system_id.system_mac);
 
     hardware.h_lport.p_element.system_id.conn_type = 0x5;
-- 
1.8.3.1

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to