lkml.org 
[lkml]   [2018]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [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

    \
     
     \ /
      Last update: 2018-07-31 22:02    [W:3.197 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site