[libvirt] [PATCH] Properly parse (unsigned) long long

This fixes problems on platforms where sizeof(long) != sizeof(long long) like ia32. --- Cheers, -- Guido python/generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/generator.py b/python/generator.py index a98a894..1ef76e1 100755 --- a/python/generator.py +++ b/python/generator.py @@ -259,8 +259,8 @@ py_types = { 'double': ('d', None, "double", "double"), 'unsigned int': ('i', None, "int", "int"), 'unsigned long': ('l', None, "long", "long"), - 'long long': ('l', None, "longlong", "long long"), - 'unsigned long long': ('l', None, "longlong", "long long"), + 'long long': ('L', None, "longlong", "long long"), + 'unsigned long long': ('K', None, "longlong", "long long"), 'unsigned char *': ('z', None, "charPtr", "char *"), 'char *': ('z', None, "charPtr", "char *"), 'const char *': ('z', None, "constcharPtr", "const char *"), -- 1.7.10.4

On 10/12/2012 05:15 PM, Guido Günther wrote:
This fixes problems on platforms where sizeof(long) != sizeof(long long) like ia32.
--- Cheers, -- Guido
python/generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/python/generator.py b/python/generator.py index a98a894..1ef76e1 100755 --- a/python/generator.py +++ b/python/generator.py @@ -259,8 +259,8 @@ py_types = { 'double': ('d', None, "double", "double"), 'unsigned int': ('i', None, "int", "int"), 'unsigned long': ('l', None, "long", "long"), - 'long long': ('l', None, "longlong", "long long"), - 'unsigned long long': ('l', None, "longlong", "long long"), + 'long long': ('L', None, "longlong", "long long"), + 'unsigned long long': ('K', None, "longlong", "long long"),
I had to look this up: http://docs.python.org/c-api/arg.html Why did you choose 'K' instead of 'L' for the unsigned version? Either we should also be using 'I' for 'unsigned int' for similar lack of overflow checking, or this should be 'L'. And since I think we want overflow checking, I'd rather see 'unsigned long long' changed to 'L'. ACK with that fix. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Fri, Oct 12, 2012 at 05:42:06PM -0600, Eric Blake wrote:
On 10/12/2012 05:15 PM, Guido Günther wrote:
This fixes problems on platforms where sizeof(long) != sizeof(long long) like ia32.
--- Cheers, -- Guido
python/generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/python/generator.py b/python/generator.py index a98a894..1ef76e1 100755 --- a/python/generator.py +++ b/python/generator.py @@ -259,8 +259,8 @@ py_types = { 'double': ('d', None, "double", "double"), 'unsigned int': ('i', None, "int", "int"), 'unsigned long': ('l', None, "long", "long"), - 'long long': ('l', None, "longlong", "long long"), - 'unsigned long long': ('l', None, "longlong", "long long"), + 'long long': ('L', None, "longlong", "long long"), + 'unsigned long long': ('K', None, "longlong", "long long"),
I had to look this up: http://docs.python.org/c-api/arg.html
Why did you choose 'K' instead of 'L' for the unsigned version? Either we should also be using 'I' for 'unsigned int' for similar lack of overflow checking, or this should be 'L'. And since I think we want overflow checking, I'd rather see 'unsigned long long' changed to 'L'. ACK with that fix.
Hmm...unsigned seemt to be a better fit but 'L' is more consistent with the current usage. Pushed with that change. Thanks, -- Guido
-- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Guido Günther