Message ID | 1441400010-15363-3-git-send-email-aconole@redhat.com |
---|---|
State | Accepted |
Headers | show |
On Fri, Sep 04, 2015 at 04:53:29PM -0400, Aaron Conole wrote: > 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 <aconole@redhat.com> Applied. I reformatted the commit message, which had a very long first long. I only saw these errors from sparse, by the way, but that's good enough for me.
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;
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 <aconole@redhat.com> --- lib/packets.h | 4 ++-- tests/test-aa.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)