[ovs-dev] [PATCH 3/3] python: Convert types.py to use UINT_MAX instead of sys.maxint.
Ethan Jackson
ethan at nicira.com
Tue Jan 4 18:14:03 UTC 2011
That makes the warnings go away, but a lot of the rest of the code is
not correct. For example, suppose self.max_length equals (sys.maxint
- 1). In that case we will be initializing the base type to (2^64 -
2) which will not properly fit in the unsigned int string length.
Same problem happens with functions like constraintsToEnglish.
That said I don't really know how important this python script is. So
if you think it's fine we can just do this simpler change.
Ethan
On Tue, Jan 4, 2011 at 11:56 AM, Ben Pfaff <blp at nicira.com> wrote:
> On Mon, Jan 03, 2011 at 12:43:29PM -0800, Ethan Jackson wrote:
>> sys.maxint represents the maximum value for an integer in python.
>> Not the maximum value for the c type "int". Thus on 64bit systems
>> it can be 2^64 - 1 which is too big for the c equivalents defined
>> in vswitch-idl.h
>
> I kind of feel like the only change that we should really be making here
> is:
>
> diff --git a/python/ovs/db/types.py b/python/ovs/db/types.py
> index d42ac7f..6b9255a 100644
> --- a/python/ovs/db/types.py
> +++ b/python/ovs/db/types.py
> @@ -358,7 +358,7 @@ class BaseType(object):
> elif self.type == StringType:
> if self.min_length is not None:
> stmts.append('%s.u.string.minLen = %d;' % (var, self.min_length))
> - if self.max_length is not None:
> + if self.max_length != sys.maxint:
> stmts.append('%s.u.string.maxLen = %d;' % (var, self.max_length))
> elif self.type == UuidType:
> if self.ref_table is not None:
>
> Won't that also solve the problem?
>
> Thanks,
>
> Ben.
>
More information about the dev
mailing list