public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Tom Parkin <tparkin@katalix•com>
To: Joe Perches <joe@perches•com>
Cc: netdev@vger•kernel.org
Subject: Re: [PATCH 17/29] l2tp: avoid precidence issues in L2TP_SKB_CB macro
Date: Tue, 28 Jul 2020 20:31:32 +0100	[thread overview]
Message-ID: <20200728193132.GB4582@katalix.com> (raw)
In-Reply-To: <bd83cd37a477721c0336807ffd2044f19f85f1d3.camel@perches.com>

[-- Attachment #1: Type: text/plain, Size: 1779 bytes --]

On  Tue, Jul 28, 2020 at 11:08:45 -0700, Joe Perches wrote:
> On Tue, 2020-07-28 at 09:21 -0700, Joe Perches wrote:
> > On Tue, 2020-07-21 at 18:32 +0100, Tom Parkin wrote:
> > > checkpatch warned about the L2TP_SKB_CB macro's use of its argument: add
> > > braces to avoid the problem.
> > []
> > > diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
> > []
> > > @@ -93,7 +93,7 @@ struct l2tp_skb_cb {
> > >  	unsigned long		expires;
> > >  };
> > >  
> > > -#define L2TP_SKB_CB(skb)	((struct l2tp_skb_cb *)&skb->cb[sizeof(struct inet_skb_parm)])
> > > +#define L2TP_SKB_CB(skb)	((struct l2tp_skb_cb *)&(skb)->cb[sizeof(struct inet_skb_parm)])
> > 
> > Likely better to use a static inline.
> > 
> > Something like:
> > 
> > static inline struct l2tp_skb_cb *L2TP_SKB_SB(struct sk_buff *skb)
> > {
> > 	return &skb->cb[sizeof(struct inet+skb_parm)];
> > }
> 
> More precisely:
> ---
>  net/l2tp/l2tp_core.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
> index e723828e458b..78ad6d8405c4 100644
> --- a/net/l2tp/l2tp_core.c
> +++ b/net/l2tp/l2tp_core.c
> @@ -93,7 +93,10 @@ struct l2tp_skb_cb {
>  	unsigned long		expires;
>  };
>  
> -#define L2TP_SKB_CB(skb)	((struct l2tp_skb_cb *)&(skb)->cb[sizeof(struct inet_skb_parm)])
> +static inline struct l2tp_skb_cb *L2TP_SKB_CB(struct sk_buff *skb)
> +{
> +	return (struct l2tp_skb_cb *)&skb->cb[sizeof(struct inet_skb_parm)];
> +}
>  
>  static struct workqueue_struct *l2tp_wq;
>  
> 

Thanks Joe.  I can see this is better since we get some type checking
from the compiler for the function argument.

The patchset has been applied already, but I can try to integrate this
change in the future.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-07-28 19:31 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-21 17:31 [PATCH net-next 00/29] l2tp: cleanup checkpatch.pl warnings Tom Parkin
2020-07-21 17:31 ` [PATCH 01/29] l2tp: cleanup whitespace around operators Tom Parkin
2020-07-21 17:31 ` [PATCH 02/29] l2tp: tweak comment style for consistency Tom Parkin
2020-07-21 17:31 ` [PATCH 03/29] l2tp: add a blank line following declarations Tom Parkin
2020-07-21 17:31 ` [PATCH 04/29] l2tp: cleanup excessive blank lines Tom Parkin
2020-07-21 17:31 ` [PATCH 05/29] l2tp: cleanup difficult-to-read line breaks Tom Parkin
2020-07-21 20:59   ` Jakub Kicinski
2020-07-21 23:26     ` David Miller
2020-07-22  9:06     ` Tom Parkin
2020-07-21 17:31 ` [PATCH 06/29] l2tp: cleanup wonky alignment of line-broken function calls Tom Parkin
2020-07-21 17:31 ` [PATCH 07/29] l2tp: cleanup suspect code indent Tom Parkin
2020-07-21 17:32 ` [PATCH 08/29] l2tp: add identifier name in function pointer prototype Tom Parkin
2020-07-21 17:32 ` [PATCH 09/29] l2tp: prefer using BIT macro Tom Parkin
2020-07-21 17:32 ` [PATCH 10/29] l2tp: cleanup comparisons to NULL Tom Parkin
2020-07-21 17:32 ` [PATCH 11/29] l2tp: cleanup unnecessary braces in if statements Tom Parkin
2020-07-21 17:32 ` [PATCH 12/29] l2tp: prefer seq_puts for unformatted output Tom Parkin
2020-07-21 17:32 ` [PATCH 13/29] l2tp: avoid multiple assignments Tom Parkin
2020-07-21 17:32 ` [PATCH 14/29] l2tp: line-break long function prototypes Tom Parkin
2020-07-21 17:32 ` [PATCH 15/29] l2tp: comment per net spinlock instances Tom Parkin
2020-07-21 17:32 ` [PATCH 16/29] l2tp: fix up incorrect comment in l2tp_recv_common Tom Parkin
2020-07-21 17:32 ` [PATCH 17/29] l2tp: avoid precidence issues in L2TP_SKB_CB macro Tom Parkin
2020-07-28 16:21   ` Joe Perches
2020-07-28 18:08     ` Joe Perches
2020-07-28 19:31       ` Tom Parkin [this message]
2020-07-21 17:32 ` [PATCH 18/29] l2tp: WARN_ON rather than BUG_ON in l2tp_debugfs.c Tom Parkin
2020-07-21 17:32 ` [PATCH 19/29] l2tp: use a function to render tunnel address in l2tp_debugfs Tom Parkin
2020-07-21 17:32 ` [PATCH 20/29] l2tp: cleanup netlink send of tunnel address information Tom Parkin
2020-07-21 17:32 ` [PATCH 21/29] l2tp: cleanup netlink tunnel create address handling Tom Parkin
2020-07-21 17:32 ` [PATCH 22/29] l2tp: cleanup kzalloc calls Tom Parkin
2020-07-21 17:32 ` [PATCH 23/29] l2tp: remove BUG_ON in l2tp_session_queue_purge Tom Parkin
2020-07-21 17:32 ` [PATCH 24/29] l2tp: remove BUG_ON in l2tp_tunnel_closeall Tom Parkin
2020-07-21 17:32 ` [PATCH 25/29] l2tp: don't BUG_ON session magic checks in l2tp_ppp Tom Parkin
2020-07-21 17:32 ` [PATCH 26/29] l2tp: don't BUG_ON seqfile " Tom Parkin
2020-07-21 17:32 ` [PATCH 27/29] l2tp: WARN_ON rather than BUG_ON in l2tp_session_queue_purge Tom Parkin
2020-07-21 17:32 ` [PATCH 28/29] l2tp: remove BUG_ON refcount value in l2tp_session_free Tom Parkin
2020-07-21 17:32 ` [PATCH 29/29] l2tp: WARN_ON rather than BUG_ON " Tom Parkin
2020-07-21 23:19 ` [PATCH net-next 00/29] l2tp: cleanup checkpatch.pl warnings David Miller
2020-07-22  9:07   ` Tom Parkin

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=20200728193132.GB4582@katalix.com \
    --to=tparkin@katalix$(echo .)com \
    --cc=joe@perches$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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