diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-04-20 14:12:22 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-04-21 06:57:47 +0200 |
commit | 93e44aa92f64f634be1c86f5b1855997bef7aaf3 (patch) | |
tree | 04a9ea060c5773cbc85f2f47ef8c013300f8e6ef /src/basic/in-addr-util.c | |
parent | Merge pull request #19371 from poettering/repart-initrd-usr-only (diff) | |
download | systemd-93e44aa92f64f634be1c86f5b1855997bef7aaf3.tar.xz systemd-93e44aa92f64f634be1c86f5b1855997bef7aaf3.zip |
in-addr-util: add assertions
Diffstat (limited to '')
-rw-r--r-- | src/basic/in-addr-util.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/basic/in-addr-util.c b/src/basic/in-addr-util.c index c11e6ceb90..13cdb9e5a5 100644 --- a/src/basic/in-addr-util.c +++ b/src/basic/in-addr-util.c @@ -803,6 +803,9 @@ int in_addr_prefix_from_string_auto_internal( } static void in_addr_data_hash_func(const struct in_addr_data *a, struct siphash *state) { + assert(a); + assert(state); + siphash24_compress(&a->family, sizeof(a->family), state); siphash24_compress(&a->address, FAMILY_ADDRESS_SIZE(a->family), state); } @@ -810,6 +813,9 @@ static void in_addr_data_hash_func(const struct in_addr_data *a, struct siphash static int in_addr_data_compare_func(const struct in_addr_data *x, const struct in_addr_data *y) { int r; + assert(x); + assert(y); + r = CMP(x->family, y->family); if (r != 0) return r; @@ -821,11 +827,15 @@ DEFINE_HASH_OPS(in_addr_data_hash_ops, struct in_addr_data, in_addr_data_hash_fu void in6_addr_hash_func(const struct in6_addr *addr, struct siphash *state) { assert(addr); + assert(state); siphash24_compress(addr, sizeof(*addr), state); } int in6_addr_compare_func(const struct in6_addr *a, const struct in6_addr *b) { + assert(a); + assert(b); + return memcmp(a, b, sizeof(*a)); } |