diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-25 17:27:11 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-27 03:11:31 +0200 |
commit | 377d89defdacecbf28be3bf58d8fb001930c5e15 (patch) | |
tree | 0d29047c3a3cdc626fa47761a6a52673c40424c4 | |
parent | 5084348e6cc7f064937f186a967fd0b394dde92d (diff) |
allowedips: fix sparse warnings in optional selftests
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | src/selftest/allowedips.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/selftest/allowedips.c b/src/selftest/allowedips.c index 74d1472..354fd78 100644 --- a/src/selftest/allowedips.c +++ b/src/selftest/allowedips.c @@ -47,7 +47,7 @@ static __init void print_node(struct allowedips_node *node, u8 bits) "\t\"%pI6/%d\"[style=%s, color=\"#%06x\"];\n"; } if (node->peer) { - hsiphash_key_t key = { 0 }; + hsiphash_key_t key = { { 0 } }; memcpy(&key, &node->peer, sizeof(node->peer)); color = hsiphash_1u32(0xdeadbeef, &key) % 200 << 16 | @@ -58,25 +58,27 @@ static __init void print_node(struct allowedips_node *node, u8 bits) swap_endian_and_apply_cidr(ip1, node->bits, bits, node->cidr); printk(fmt_declaration, ip1, node->cidr, style, color); if (node->bit[0]) { - swap_endian_and_apply_cidr(ip2, node->bit[0]->bits, bits, - node->cidr); + swap_endian_and_apply_cidr(ip2, + rcu_dereference_raw(node->bit[0])->bits, bits, + node->cidr); printk(fmt_connection, ip1, node->cidr, ip2, - node->bit[0]->cidr); - print_node(node->bit[0], bits); + rcu_dereference_raw(node->bit[0])->cidr); + print_node(rcu_dereference_raw(node->bit[0]), bits); } if (node->bit[1]) { - swap_endian_and_apply_cidr(ip2, node->bit[1]->bits, bits, - node->cidr); + swap_endian_and_apply_cidr(ip2, + rcu_dereference_raw(node->bit[1])->bits, + bits, node->cidr); printk(fmt_connection, ip1, node->cidr, ip2, - node->bit[1]->cidr); - print_node(node->bit[1], bits); + rcu_dereference_raw(node->bit[1])->cidr); + print_node(rcu_dereference_raw(node->bit[1]), bits); } } -static __init void print_tree(struct allowedips_node *top, u8 bits) +static __init void print_tree(struct allowedips_node __rcu *top, u8 bits) { printk(KERN_DEBUG "digraph trie {\n"); - print_node(top, bits); + print_node(rcu_dereference_raw(top), bits); printk(KERN_DEBUG "}\n"); } @@ -122,7 +124,7 @@ static __init inline union nf_inet_addr horrible_cidr_to_mask(u8 cidr) memset(&mask, 0x00, 128 / 8); memset(&mask, 0xff, cidr / 8); if (cidr % 32) - mask.all[cidr / 32] = htonl( + mask.all[cidr / 32] = (__force u32)htonl( (0xFFFFFFFFUL << (32 - (cidr % 32))) & 0xFFFFFFFFUL); return mask; } |