Skip to content

Commit

Permalink
Warning: Fix for Unsigned long long usage in 32bit arch using ULL mac…
Browse files Browse the repository at this point in the history
…ro (#993)

Signed-off-by: Antony Rheneus <arheneus@marvell.com>
  • Loading branch information
antony-rheneus authored and lguohan committed Aug 8, 2019
1 parent b62c337 commit 5d2df18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion meta/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ WARNINGS = \
-Winit-self \
-Winline \
-Winvalid-pch \
-Wlong-long \
-Wmissing-field-initializers \
-Wmissing-format-attribute \
-Wmissing-include-dirs \
Expand Down
19 changes: 12 additions & 7 deletions meta/saiserialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,10 +850,12 @@ int sai_serialize_ip6_mask(
_In_ const sai_ip6_t mask)
{
uint32_t n = 64;
uint64_t tmp = 0xFFFFFFFFFFFFFFFFUL;
uint64_t tmp = UINT64_C(0xFFFFFFFFFFFFFFFF);

uint64_t high = *((const uint64_t*)mask);
uint64_t low = *((const uint64_t*)mask + 1);
uint64_t high;
uint64_t low;
memcpy(&high, (const uint8_t*)mask, sizeof(uint64_t));
memcpy(&low, ((const uint8_t*)mask + sizeof(uint64_t)), sizeof(uint64_t));

high = __builtin_bswap64(high);
low = __builtin_bswap64(low);
Expand Down Expand Up @@ -899,8 +901,9 @@ int sai_deserialize_ip6_mask(
return SAI_SERIALIZE_ERROR;
}

uint64_t high = 0xFFFFFFFFFFFFFFFFUL;
uint64_t low = 0xFFFFFFFFFFFFFFFFUL;
uint64_t high = UINT64_C(0xFFFFFFFFFFFFFFFF);
uint64_t low = UINT64_C(0xFFFFFFFFFFFFFFFF);
uint64_t tmp;

if (value == 128)
{
Expand All @@ -924,8 +927,10 @@ int sai_deserialize_ip6_mask(
low = 0;
}

*((uint64_t*)mask) = __builtin_bswap64(high);
*((uint64_t*)mask + 1) = __builtin_bswap64(low);
tmp = __builtin_bswap64(high);
memcpy((uint8_t*)mask, &tmp, sizeof(uint64_t));
tmp = __builtin_bswap64(low);
memcpy(((uint8_t*)mask + sizeof(uint64_t)), &tmp, sizeof(uint64_t));

return res;
}
Expand Down

0 comments on commit 5d2df18

Please sign in to comment.