All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David Laight" <David.Laight@ACULAB.COM>
To: "David Miller" <davem@davemloft.net>, <yangyingliang@huawei.com>
Cc: <netdev@vger.kernel.org>
Subject: RE: [PATCH net-next 6/6] net_sched: make macro be enclosed in parenthesis
Date: Wed, 11 Dec 2013 10:20:32 -0000	[thread overview]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6026B747A@saturn3.aculab.com> (raw)
In-Reply-To: <20131210.224900.1427512059771492387.davem@davemloft.net>

> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org] On Behalf Of David Miller
> From: Yang Yingliang <yangyingliang@huawei.com>
> Date: Tue, 10 Dec 2013 20:55:34 +0800
> 
> > Macros with complex values should be enclosed in parenthesis
> >
> > Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> > ---
> >  net/sched/em_meta.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
> > index e5cef956..852cd62 100644
> > --- a/net/sched/em_meta.c
> > +++ b/net/sched/em_meta.c
> > @@ -272,10 +272,12 @@ META_COLLECTOR(int_rtiif)
> >   **************************************************************************/
> >
> >  #define SKIP_NONLOCAL(skb)			\
> > +({						\
> >  	if (unlikely(skb->sk == NULL)) {	\
> >  		*err = -1;			\
> >  		return;				\
> > -	}
> > +	}					\
> > +})
> 
> I can't apply this.
> 
> First of all, "({ })" is for statements that evaluate to an lvalue,
> this macro does not.
> 
> Second of all, and more importantly, this macro needs to be eliminated
> entirely.  It completely hides control flow, and in the past we've
> killed macros which do this such as the old netlink attribute
> builders.
> 
> The control flow should be inlined and expanded explicitly in the
> code so that someone who reads it can tell the control flow can
> be changed by the statement.  Compare:
> 
> 	SKIP_NONLOCAL(skb)
> 
> to:
> 
> 	if (skip_nonlocal(skb)) {
> 		*err = -1;
> 		return;
> 	}

Or:
	if (!skb->sk)
		goto no_sk;
	...
	return;

no_sk:
	*err = -1;
	return;

Actually WTF is a void function doing having an 'int *err' argument?
These should just be:
	if (!skb->sk)
		return -1;

	David

      parent reply	other threads:[~2013-12-11 10:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-10 12:55 [PATCH net-next 0/6] net_sched: clean up some chekpatch errors Yang Yingliang
2013-12-10 12:55 ` [PATCH net-next 1/6] net_sched: remove unnecessary parentheses while return Yang Yingliang
2013-12-11  3:46   ` David Miller
2013-12-10 12:55 ` [PATCH net-next 2/6] net_sched: cls_bpf: use tabs to do indent Yang Yingliang
2013-12-11  3:46   ` David Miller
2013-12-10 12:55 ` [PATCH net-next 3/6] net_sched: change "foo* bar" to "foo *bar" Yang Yingliang
2013-12-11  3:46   ` David Miller
2013-12-10 12:55 ` [PATCH net-next 4/6] net_sched: add space around '>' and before '(' Yang Yingliang
2013-12-11  3:46   ` David Miller
2013-12-10 12:55 ` [PATCH net-next 5/6] net_sched: sfq: put sfq_unlink in a do - while loop Yang Yingliang
2013-12-11  3:47   ` David Miller
2013-12-10 12:55 ` [PATCH net-next 6/6] net_sched: make macro be enclosed in parenthesis Yang Yingliang
2013-12-10 13:01   ` David Laight
2013-12-11  2:16     ` Yang Yingliang
2013-12-11  3:49   ` David Miller
2013-12-11  7:17     ` [PATCH net-next] net_sched: expand control flow of macro SKIP_NONLOCAL Yang Yingliang
2013-12-11 17:29       ` David Miller
2013-12-11 10:20     ` David Laight [this message]

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=AE90C24D6B3A694183C094C60CF0A2F6026B747A@saturn3.aculab.com \
    --to=david.laight@aculab.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=yangyingliang@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.