Re: [PATCH v1 3/3] net: WireGuard secure network tunnel

From
Andrew Lunn <andrew@lunn.ch>
Date
2018-07-31 20:02:32
Also in
lkml
Reply to
Jason A. Donenfeld, 2018-07-31
Hi Jason

I just gave this patch to checkpatch.pl...

total: 6 errors, 763 warnings, 6514 lines checked

It would be good to reduce these numbers.
+static __always_inline void swap_endian(u8 *dst, const u8 *src, u8 bits)
There is a general preference to not force the compile to
inline. Leave it to decide.
quoted hunk ↗ jump to hunk
+#define push(stack, p, len) ({ \
+	if (rcu_access_pointer(p)) { \
+		BUG_ON(len >= 128); \
+		stack[len++] = rcu_dereference_protected(p, lockdep_is_held(lock)); \
+	} \
+	true; \
+})
+#undef push
+
+#define push(p) ({ BUG_ON(len >= 128); stack[len++] = p; })
This is going to lead to bugs, coders thinking push() does one thing,
when it actually does something else. I would suggest making these
helper functions, with useful names.
quoted hunk ↗ jump to hunk
+/* Returns a strong reference to a peer */
+static __always_inline struct wireguard_peer *lookup(struct allowedips_node __rcu *root, u8 bits, const void *be_ip)
+{
+	struct wireguard_peer *peer = NULL;
+	struct allowedips_node *node;
+	u8 ip[16] __aligned(__alignof(u64));
netdev code requires that all local variables are in reverse christmas tree.

       Andrew
Thread (21 messages) 21 messages, 8 authors, last reply 2018-08-22
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help