From 37ba4764eba8047ccf934e8b796ba7104eec9a7a Mon Sep 17 00:00:00 2001 From: Aaron Conole Date: Fri, 4 Sep 2015 16:53:29 -0400 Subject: [PATCH] packets: Avoid compile errors. Commit 74ff3298c880 (userspace: Define and use struct eth_addr.) introduced a compilation issue due to a bad unsigned 64-bit constant, as well as an implicit narrow. 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 Signed-off-by: Ben Pfaff --- 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 fd235dcf3..a4f63839b 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 0b0e25662..2da572d1b 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; -- 2.20.1