netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	davem@davemloft.net, Greg KH <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v1 3/3] net: WireGuard secure network tunnel
Date: Tue, 31 Jul 2018 22:02:23 +0200	[thread overview]
Message-ID: <20180731200223.GA32125@lunn.ch> (raw)
In-Reply-To: <20180731191102.2434-4-Jason@zx2c4.com>

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

  reply	other threads:[~2018-07-31 21:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31 19:10 [PATCH v1 0/3] WireGuard: Secure Network Tunnel Jason A. Donenfeld
2018-07-31 19:11 ` [PATCH v1 1/3] random: Make crng state queryable Jason A. Donenfeld
2018-08-02 21:35   ` Theodore Y. Ts'o
2018-07-31 19:11 ` [PATCH v1 2/3] zinc: Introduce minimal cryptography library Jason A. Donenfeld
2018-07-31 19:11 ` [PATCH v1 3/3] net: WireGuard secure network tunnel Jason A. Donenfeld
2018-07-31 20:02   ` Andrew Lunn [this message]
2018-07-31 20:22   ` Stephen Hemminger
2018-08-21 23:41     ` Jason A. Donenfeld
2018-08-21 23:54       ` David Miller
2018-08-21 23:59         ` Jason A. Donenfeld
2018-08-22  0:23           ` Andrew Lunn
2018-07-31 20:27   ` Stephen Hemminger
2018-08-03  0:35     ` Jason A. Donenfeld
2018-08-03 14:39       ` Andrew Lunn
2018-08-01  1:21   ` Shawn Landden
2018-08-13 15:40 ` [PATCH v1 0/3] WireGuard: Secure Network Tunnel James Bottomley
2018-08-13 15:53   ` Willy Tarreau
2018-08-13 17:02   ` Jason A. Donenfeld
2018-08-13 17:37     ` James Bottomley
2018-08-13 17:55       ` Jason A. Donenfeld
2018-08-13 18:04         ` James Bottomley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180731200223.GA32125@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=Jason@zx2c4.com \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).