diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-08 22:54:32 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-09 01:57:47 +0200 |
commit | f985de2c5acc9a9086829d52237fce0d2a663277 (patch) | |
tree | 28ce187bcd7aad1e03ab92f7ec9695d343f44973 /src/allowedips.c | |
parent | main: change module description (diff) | |
download | wireguard-monolithic-historical-f985de2c5acc9a9086829d52237fce0d2a663277.tar.xz wireguard-monolithic-historical-f985de2c5acc9a9086829d52237fce0d2a663277.zip |
global: give if statements brackets and other cleanups
Diffstat (limited to 'src/allowedips.c')
-rw-r--r-- | src/allowedips.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/allowedips.c b/src/allowedips.c index 8699fb1..bc43b71 100644 --- a/src/allowedips.c +++ b/src/allowedips.c @@ -20,9 +20,9 @@ struct allowedips_node { static __always_inline void swap_endian(u8 *dst, const u8 *src, u8 bits) { - if (bits == 32) + if (bits == 32) { *(u32 *)dst = be32_to_cpu(*(const __be32 *)src); - else if (bits == 128) { + } else if (bits == 128) { ((u64 *)dst)[0] = be64_to_cpu(((const __be64 *)src)[0]); ((u64 *)dst)[1] = be64_to_cpu(((const __be64 *)src)[1]); } @@ -50,8 +50,8 @@ static void node_free_rcu(struct rcu_head *rcu) #define push_rcu(stack, p, len) ({ \ if (rcu_access_pointer(p)) { \ - WARN_ON(IS_ENABLED(DEBUG) && len >= 128); \ - stack[len++] = rcu_dereference_raw(p); \ + WARN_ON(IS_ENABLED(DEBUG) && (len) >= 128); \ + stack[(len)++] = rcu_dereference_raw(p); \ } \ true; \ }) @@ -104,14 +104,16 @@ walk_by_peer(struct allowedips_node __rcu *top, u8 bits, } return 0; } + #undef push_rcu #define ref(p) rcu_access_pointer(p) -#define deref(p) rcu_dereference_protected(*p, lockdep_is_held(lock)) +#define deref(p) rcu_dereference_protected(*(p), lockdep_is_held(lock)) #define push(p) ({ \ WARN_ON(IS_ENABLED(DEBUG) && len >= 128); \ stack[len++] = p; \ }) + static void walk_remove_by_peer(struct allowedips_node __rcu **top, struct wg_peer *peer, struct mutex *lock) { @@ -153,6 +155,7 @@ static void walk_remove_by_peer(struct allowedips_node __rcu **top, } } } + #undef ref #undef deref #undef push @@ -181,7 +184,7 @@ static __always_inline u8 common_bits(const struct allowedips_node *node, * this instead. */ #define prefix_matches(node, key, bits) \ - (common_bits(node, key, bits) >= node->cidr) + (common_bits(node, key, bits) >= (node)->cidr) static __always_inline struct allowedips_node * find_node(struct allowedips_node *trie, u8 bits, const u8 *key) @@ -270,9 +273,9 @@ static int add(struct allowedips_node __rcu **trie, u8 bits, const u8 *key, RCU_INIT_POINTER(newnode->peer, peer); copy_and_assign_cidr(newnode, key, cidr, bits); - if (!node) + if (!node) { down = rcu_dereference_protected(*trie, lockdep_is_held(lock)); - else { + } else { down = rcu_dereference_protected(choose_node(node, key), lockdep_is_held(lock)); if (!down) { |