[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180731200223.GA32125@lunn.ch>
Date: Tue, 31 Jul 2018 22:02:23 +0200
From: Andrew Lunn <andrew@...n.ch>
To: "Jason A. Donenfeld" <Jason@...c4.com>
Cc: linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
davem@...emloft.net, Greg KH <gregkh@...uxfoundation.org>
Subject: Re: [PATCH v1 3/3] net: WireGuard secure network tunnel
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.
> +#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.
> +/* 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
Powered by blists - more mailing lists