summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLisandro Dalcin <dalcinl@gmail.com>2014-11-21 12:55:04 +0300
committerLisandro Dalcin <dalcinl@gmail.com>2014-11-21 12:55:04 +0300
commit9e2adc7437a6b28a848b045f4953919744e5704b (patch)
tree5a97964e984c7a9d1f3528507cb4baf1a7c43c4d
parentb8236fdb96f73612822a5d883a881521783a2625 (diff)
downloadcffi-9e2adc7437a6b28a848b045f4953919744e5704b.tar.gz
CPython: Add explicit typecasts in _cffi_from_c_int()
-rw-r--r--cffi/vengine_cpy.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/cffi/vengine_cpy.py b/cffi/vengine_cpy.py
index ec1b80d..8a2aa18 100644
--- a/cffi/vengine_cpy.py
+++ b/cffi/vengine_cpy.py
@@ -829,12 +829,15 @@ cffimod_header = r'''
PyLong_FromLongLong((long long)(x)))
#define _cffi_from_c_int(x, type) \
- (((type)-1) > 0 ? /* unsigned */ \
- (sizeof(type) < sizeof(long) ? PyInt_FromLong(x) : \
- sizeof(type) == sizeof(long) ? PyLong_FromUnsignedLong(x) : \
- PyLong_FromUnsignedLongLong(x)) \
- : (sizeof(type) <= sizeof(long) ? PyInt_FromLong(x) : \
- PyLong_FromLongLong(x)))
+ (((type)-1) > 0 ? /* unsigned */ \
+ (sizeof(type) < sizeof(long) ? \
+ PyInt_FromLong((long)x) : \
+ sizeof(type) == sizeof(long) ? \
+ PyLong_FromUnsignedLong((unsigned long)x) : \
+ PyLong_FromUnsignedLongLong((unsigned long long)x)) : \
+ (sizeof(type) <= sizeof(long) ? \
+ PyInt_FromLong((long)x) : \
+ PyLong_FromLongLong((long long)x)))
#define _cffi_to_c_int(o, type) \
(sizeof(type) == 1 ? (((type)-1) > 0 ? (type)_cffi_to_c_u8(o) \