netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] openvswitch: using nla_for_each_X to simplify the code
@ 2012-10-07 13:42 Wei Yongjun
  2012-10-07 18:30 ` Jesse Gross
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Yongjun @ 2012-10-07 13:42 UTC (permalink / raw)
  To: jesse-l0M0P4e3n4LQT0dZR+AlfA, davem-fT/PcQaiUtIeIZ0/mPfg9Q
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, netdev-u79uwXL29TY76Z2rM5mHXA,
	yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY

From: Wei Yongjun <yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org>

Using nla_for_each_nested() or nla_for_each_attr()
to simplify the code.

dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)

Signed-off-by: Wei Yongjun <yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org>
---
 net/openvswitch/actions.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 0811447..b67594f 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -288,8 +288,7 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb,
 	upcall.userdata = NULL;
 	upcall.portid = 0;
 
-	for (a = nla_data(attr), rem = nla_len(attr); rem > 0;
-		 a = nla_next(a, &rem)) {
+	nla_for_each_nested(a, attr, rem) {
 		switch (nla_type(a)) {
 		case OVS_USERSPACE_ATTR_USERDATA:
 			upcall.userdata = a;
@@ -311,8 +310,7 @@ static int sample(struct datapath *dp, struct sk_buff *skb,
 	const struct nlattr *a;
 	int rem;
 
-	for (a = nla_data(attr), rem = nla_len(attr); rem > 0;
-		 a = nla_next(a, &rem)) {
+	nla_for_each_nested(a, attr, rem) {
 		switch (nla_type(a)) {
 		case OVS_SAMPLE_ATTR_PROBABILITY:
 			if (net_random() >= nla_get_u32(a))
@@ -371,8 +369,7 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
 	const struct nlattr *a;
 	int rem;
 
-	for (a = attr, rem = len; rem > 0;
-	     a = nla_next(a, &rem)) {
+	nla_for_each_attr(a, attr, len, rem) {
 		int err = 0;
 
 		if (prev_port != -1) {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] openvswitch: using nla_for_each_X to simplify the code
  2012-10-07 13:42 [PATCH] openvswitch: using nla_for_each_X to simplify the code Wei Yongjun
@ 2012-10-07 18:30 ` Jesse Gross
       [not found]   ` <CAEP_g=_D1m+p0POKC5ozFEgfEhGzN9G_+Yja_iBz4guuRe6Nog-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Jesse Gross @ 2012-10-07 18:30 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: davem, yongjun_wei, dev, netdev

On Sun, Oct 7, 2012 at 6:42 AM, Wei Yongjun <weiyj.lk@gmail.com> wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> Using nla_for_each_nested() or nla_for_each_attr()
> to simplify the code.
>
> dpatch engine is used to auto generate this patch.
> (https://github.com/weiyj/dpatch)
>
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

It is done this way intentionally to avoid checks on the fast path for
conditions that have already been validated.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] openvswitch: using nla_for_each_X to simplify the code
       [not found]   ` <CAEP_g=_D1m+p0POKC5ozFEgfEhGzN9G_+Yja_iBz4guuRe6Nog-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2012-10-07 18:33     ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2012-10-07 18:33 UTC (permalink / raw)
  To: jesse-l0M0P4e3n4LQT0dZR+AlfA
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, netdev-u79uwXL29TY76Z2rM5mHXA,
	yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY,
	weiyj.lk-Re5JQEeQqe8AvxtiuMwx3w

From: Jesse Gross <jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
Date: Sun, 7 Oct 2012 11:30:51 -0700

> On Sun, Oct 7, 2012 at 6:42 AM, Wei Yongjun <weiyj.lk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> From: Wei Yongjun <yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org>
>>
>> Using nla_for_each_nested() or nla_for_each_attr()
>> to simplify the code.
>>
>> dpatch engine is used to auto generate this patch.
>> (https://github.com/weiyj/dpatch)
>>
>> Signed-off-by: Wei Yongjun <yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org>
> 
> It is done this way intentionally to avoid checks on the fast path for
> conditions that have already been validated.

Agreed, I'm not applying this patch.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-07 18:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-07 13:42 [PATCH] openvswitch: using nla_for_each_X to simplify the code Wei Yongjun
2012-10-07 18:30 ` Jesse Gross
     [not found]   ` <CAEP_g=_D1m+p0POKC5ozFEgfEhGzN9G_+Yja_iBz4guuRe6Nog-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-07 18:33     ` David Miller

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).