aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-10-25 17:27:11 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-27 03:11:31 +0200
commit088576d031403350417d57fe950045b79bd7ff5f (patch)
tree0b58a03bc4c2711b630e0d927406fa327daa7b78
parentpoly1305-donna64: mark large constants as ULL (diff)
downloadwireguard-monolithic-historical-088576d031403350417d57fe950045b79bd7ff5f.tar.xz
wireguard-monolithic-historical-088576d031403350417d57fe950045b79bd7ff5f.zip
allowedips: fix sparse warnings in optional selftests
-rw-r--r--src/selftest/allowedips.c26
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;
}