siphash24: introduce siphash24_compress_typesafe() macro

To prevent copy-and-paste mistake.

This also introduce in_addr_hash_func().

No functional change, just refactoring.
This commit is contained in:
Yu Watanabe
2023-12-25 15:38:59 +09:00
parent ac1b7b9e19
commit c01a5c0527
38 changed files with 177 additions and 162 deletions
+3 -3
View File
@@ -59,8 +59,8 @@ void hw_addr_hash_func(const struct hw_addr_data *p, struct siphash *state) {
assert(p);
assert(state);
siphash24_compress(&p->length, sizeof(p->length), state);
siphash24_compress(p->bytes, p->length, state);
siphash24_compress_typesafe(p->length, state);
siphash24_compress_safe(p->bytes, p->length, state);
}
DEFINE_HASH_OPS(hw_addr_hash_ops, struct hw_addr_data, hw_addr_hash_func, hw_addr_compare);
@@ -106,7 +106,7 @@ int ether_addr_compare(const struct ether_addr *a, const struct ether_addr *b) {
}
static void ether_addr_hash_func(const struct ether_addr *p, struct siphash *state) {
siphash24_compress(p, sizeof(struct ether_addr), state);
siphash24_compress_typesafe(*p, state);
}
DEFINE_HASH_OPS(ether_addr_hash_ops, struct ether_addr, ether_addr_hash_func, ether_addr_compare);