We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6dfad66 commit d814d2cCopy full SHA for d814d2c
meta/MetaKeyHasher.cpp
@@ -160,12 +160,20 @@ static inline std::size_t sai_get_hash(
160
return ne.ip_address.addr_family;
161
}
162
163
+static_assert(sizeof(uint32_t) == 4, "uint32_t expected to be 4 bytes");
164
+
165
static inline std::size_t sai_get_hash(
166
_In_ const sai_fdb_entry_t& fe)
167
{
168
SWSS_LOG_ENTER();
169
- return *(const uint32_t*)(&fe.mac_address[2]);
170
+ uint32_t data;
171
172
+ // use low 4 bytes of mac address as hash value
173
+ // use memcpy instead of cast because of strict-aliasing rules
174
+ memcpy(&data, fe.mac_address + 2, sizeof(uint32_t));
175
176
+ return data;
177
178
179
0 commit comments