diff mbox series

[ovs-dev,14/15] json: Make it safe to pass null pointers to json_equal().

Message ID 20180101051640.13043-14-blp@ovn.org
State Accepted
Delegated to: Justin Pettit
Headers show
Series [ovs-dev,01/15] log: Add async commit support. | expand

Commit Message

Ben Pfaff Jan. 1, 2018, 5:16 a.m. UTC
Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 lib/json.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Yifeng Sun Jan. 16, 2018, 5:13 p.m. UTC | #1
Looks good to me, thanks for the patch.

Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>

On Sun, Dec 31, 2017 at 9:16 PM, Ben Pfaff <blp@ovn.org> wrote:

> Signed-off-by: Ben Pfaff <blp@ovn.org>
> ---
>  lib/json.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lib/json.c b/lib/json.c
> index 5e93190b8a03..07ca87b2130f 100644
> --- a/lib/json.c
> +++ b/lib/json.c
> @@ -576,9 +576,9 @@ json_equal(const struct json *a, const struct json *b)
>  {
>      if (a == b) {
>          return true;
> -    }
> -
> -    if (a->type != b->type) {
> +    } else if (!a || !b) {
> +        return false;
> +    } else if (a->type != b->type) {
>          return false;
>      }
>
> --
> 2.10.2
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Ben Pfaff Jan. 22, 2018, 7:30 p.m. UTC | #2
Thanks for the review!

On Tue, Jan 16, 2018 at 09:13:43AM -0800, Yifeng Sun wrote:
> Looks good to me, thanks for the patch.
> 
> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
> 
> On Sun, Dec 31, 2017 at 9:16 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> > ---
> >  lib/json.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/lib/json.c b/lib/json.c
> > index 5e93190b8a03..07ca87b2130f 100644
> > --- a/lib/json.c
> > +++ b/lib/json.c
> > @@ -576,9 +576,9 @@ json_equal(const struct json *a, const struct json *b)
> >  {
> >      if (a == b) {
> >          return true;
> > -    }
> > -
> > -    if (a->type != b->type) {
> > +    } else if (!a || !b) {
> > +        return false;
> > +    } else if (a->type != b->type) {
> >          return false;
> >      }
> >
> > --
> > 2.10.2
> >
> > _______________________________________________
> > dev mailing list
> > dev@openvswitch.org
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> >
Justin Pettit Feb. 5, 2018, 10:38 p.m. UTC | #3
> On Dec 31, 2017, at 9:16 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> Signed-off-by: Ben Pfaff <blp@ovn.org>

Acked-by: Justin Pettit <jpettit@ovn.org>

--Justin
Ben Pfaff Feb. 6, 2018, 7:17 p.m. UTC | #4
On Mon, Feb 05, 2018 at 02:38:30PM -0800, Justin Pettit wrote:
> 
> 
> > On Dec 31, 2017, at 9:16 PM, Ben Pfaff <blp@ovn.org> wrote:
> > 
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> 
> Acked-by: Justin Pettit <jpettit@ovn.org>

Thanks.  I applied this patch (only) to master.
diff mbox series

Patch

diff --git a/lib/json.c b/lib/json.c
index 5e93190b8a03..07ca87b2130f 100644
--- a/lib/json.c
+++ b/lib/json.c
@@ -576,9 +576,9 @@  json_equal(const struct json *a, const struct json *b)
 {
     if (a == b) {
         return true;
-    }
-
-    if (a->type != b->type) {
+    } else if (!a || !b) {
+        return false;
+    } else if (a->type != b->type) {
         return false;
     }