[ovs-dev] put bundle_lookup ahead to simplify the code

Message ID CALttK1RuvV138kNT4w+EbAbji=U6Bn16BZVQ5nOjf7dV6stWnA@mail.gmail.com
State Accepted
Headers show
Series
  • [ovs-dev] put bundle_lookup ahead to simplify the code
Related show

Commit Message

duanjiong Sept. 8, 2017, 1:51 a.m.
From ba48275f8bb30ed2888c16426726ee9cb3407cd1 Mon Sep 17 00:00:00 2001
From: Duan Jiong <djduanjiong@gmail.com>
Date: Fri, 8 Sep 2017 09:48:59 +0800
Subject: [PATCH] put bundle_lookup ahead to simplify the code

Signed-off-by: Duan Jiong <djduanjiong@gmail.com>
---
 ofproto/ofproto-dpif.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Gregory Rose Sept. 12, 2017, 9:31 p.m. | #1
On 09/07/2017 06:51 PM, Duan Jiong wrote:
>  From ba48275f8bb30ed2888c16426726ee9cb3407cd1 Mon Sep 17 00:00:00 2001
> From: Duan Jiong <djduanjiong@gmail.com>
> Date: Fri, 8 Sep 2017 09:48:59 +0800
> Subject: [PATCH] put bundle_lookup ahead to simplify the code
> 
> Signed-off-by: Duan Jiong <djduanjiong@gmail.com>
> ---
>   ofproto/ofproto-dpif.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> index 1a8e829..293780f 100644
> --- a/ofproto/ofproto-dpif.c
> +++ b/ofproto/ofproto-dpif.c
> @@ -3011,15 +3011,16 @@ bundle_set(struct ofproto *ofproto_, void *aux,
>       size_t i;
>       bool ok;
> 
> +    bundle = bundle_lookup(ofproto, aux);
> +
>       if (!s) {
> -        bundle_destroy(bundle_lookup(ofproto, aux));
> +        bundle_destroy(bundle);
>           return 0;
>       }
> 
>       ovs_assert(s->n_slaves == 1 || s->bond != NULL);
>       ovs_assert((s->lacp != NULL) == (s->lacp_slaves != NULL));
> 
> -    bundle = bundle_lookup(ofproto, aux);
>       if (!bundle) {
>           bundle = xmalloc(sizeof *bundle);
> 

Makes sense...

Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Ben Pfaff Nov. 3, 2017, 7:28 p.m. | #2
On Tue, Sep 12, 2017 at 02:31:07PM -0700, Greg Rose wrote:
> On 09/07/2017 06:51 PM, Duan Jiong wrote:
> > From ba48275f8bb30ed2888c16426726ee9cb3407cd1 Mon Sep 17 00:00:00 2001
> >From: Duan Jiong <djduanjiong@gmail.com>
> >Date: Fri, 8 Sep 2017 09:48:59 +0800
> >Subject: [PATCH] put bundle_lookup ahead to simplify the code
> >
> >Signed-off-by: Duan Jiong <djduanjiong@gmail.com>
> >---
> >  ofproto/ofproto-dpif.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> >diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> >index 1a8e829..293780f 100644
> >--- a/ofproto/ofproto-dpif.c
> >+++ b/ofproto/ofproto-dpif.c
> >@@ -3011,15 +3011,16 @@ bundle_set(struct ofproto *ofproto_, void *aux,
> >      size_t i;
> >      bool ok;
> >
> >+    bundle = bundle_lookup(ofproto, aux);
> >+
> >      if (!s) {
> >-        bundle_destroy(bundle_lookup(ofproto, aux));
> >+        bundle_destroy(bundle);
> >          return 0;
> >      }
> >
> >      ovs_assert(s->n_slaves == 1 || s->bond != NULL);
> >      ovs_assert((s->lacp != NULL) == (s->lacp_slaves != NULL));
> >
> >-    bundle = bundle_lookup(ofproto, aux);
> >      if (!bundle) {
> >          bundle = xmalloc(sizeof *bundle);
> >
> 
> Makes sense...
> 
> Reviewed-by: Greg Rose <gvrose8192@gmail.com>

I applied this to master.  Thanks, Duan and Greg.

(Again, I apologize for the delay.)

Patch

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 1a8e829..293780f 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -3011,15 +3011,16 @@  bundle_set(struct ofproto *ofproto_, void *aux,
     size_t i;
     bool ok;

+    bundle = bundle_lookup(ofproto, aux);
+
     if (!s) {
-        bundle_destroy(bundle_lookup(ofproto, aux));
+        bundle_destroy(bundle);
         return 0;
     }

     ovs_assert(s->n_slaves == 1 || s->bond != NULL);
     ovs_assert((s->lacp != NULL) == (s->lacp_slaves != NULL));

-    bundle = bundle_lookup(ofproto, aux);
     if (!bundle) {
         bundle = xmalloc(sizeof *bundle);