On Tue, Aug 23, 2011 at 2:05 PM, Ben Pfaff <b...@nicira.com> wrote:

> Suggested-by: Reid Price <r...@nicira.com>
> ---
>  lib/ovsdb-types.c       |    3 +--
>  python/ovs/db/data.py   |    2 +-
>  python/ovs/db/parser.py |    4 ++--
>  python/ovs/db/types.py  |    8 +++-----
>  4 files changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/lib/ovsdb-types.c b/lib/ovsdb-types.c
> index b3452dd..959f087 100644
> --- a/lib/ovsdb-types.c
> +++ b/lib/ovsdb-types.c
> @@ -1,4 +1,4 @@
> -/* Copyright (c) 2009, 2010 Nicira Networks
> +/* Copyright (c) 2009, 2010, 2011 Nicira Networks
>  *
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
> @@ -556,7 +556,6 @@ ovsdb_type_is_valid(const struct ovsdb_type *type)
>             && ovsdb_base_type_is_valid(&type->key)
>             && ovsdb_base_type_is_valid(&type->value)
>             && type->n_min <= 1
> -            && type->n_min <= type->n_max
>

I assume this one is on purpose too


>             && type->n_max >= 1);
>  }
>
> diff --git a/python/ovs/db/data.py b/python/ovs/db/data.py
> index eb3060d..7cf5eac 100644
> --- a/python/ovs/db/data.py
> +++ b/python/ovs/db/data.py
> @@ -402,7 +402,7 @@ class Datum(object):
>
>     def conforms_to_type(self):
>         n = len(self.values)
> -        return n >= self.type.n_min and n <= self.type.n_max
> +        return self.type.n_min <= n <= self.type.n_max
>
>     def cInitDatum(self, var):
>         if len(self.values) == 0:
> diff --git a/python/ovs/db/parser.py b/python/ovs/db/parser.py
> index 8858f00..073f760 100644
> --- a/python/ovs/db/parser.py
> +++ b/python/ovs/db/parser.py
> @@ -1,4 +1,4 @@
> -# Copyright (c) 2010 Nicira Networks
> +# Copyright (c) 2010, 2011 Nicira Networks
>  #
>  # Licensed under the Apache License, Version 2.0 (the "License");
>  # you may not use this file except in compliance with the License.
> @@ -67,7 +67,7 @@ def float_to_int(x):
>     # XXX still needed?
>     if type(x) == float:
>         integer = int(x)
> -        if integer == x and integer >= -2**53 and integer < 2**53:
> +        if integer == x and -2**53 <= integer < 2**53:
>             return integer
>     return x
>
> diff --git a/python/ovs/db/types.py b/python/ovs/db/types.py
> index ded9f5f..635922f 100644
> --- a/python/ovs/db/types.py
> +++ b/python/ovs/db/types.py
> @@ -141,7 +141,7 @@ class BaseType(object):
>             value = default
>         else:
>             max_value = 2**32 - 1
> -            if value < 0 or value > max_value:
> +            if not (0 <= value <= max_value):
>                 raise error.Error("%s out of valid range 0 to %d"
>                                   % (name, max_value), value)
>         return value
> @@ -396,9 +396,7 @@ class Type(object):
>         return (self.key.type != VoidType and self.key.is_valid() and
>                 (self.value is None or
>                  (self.value.type != VoidType and self.value.is_valid()))
> and
> -                self.n_min <= 1 and
> -                self.n_min <= self.n_max and
> -                self.n_max >= 1)
> +                self.n_min <= 1 <= self.n_max)
>
>     def is_scalar(self):
>         return self.n_min == 1 and self.n_max == 1 and not self.value
> @@ -423,7 +421,7 @@ class Type(object):
>     def __n_from_json(json, default):
>         if json is None:
>             return default
> -        elif type(json) == int and json >= 0 and json <= sys.maxint:
> +        elif type(json) == int and 0 <= json <= sys.maxint:
>             return json
>         else:
>             raise error.Error("bad min or max value", json)
> --
> 1.7.4.4
>
>
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to