[pypy-commit] cffi cpy-extension: More tweaks, preventing a compiler warning

arigo noreply at buildbot.pypy.org
Thu Jun 14 10:10:03 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: cpy-extension
Changeset: r320:6c0c72f0ecb8
Date: 2012-06-14 10:09 +0200
http://bitbucket.org/cffi/cffi/changeset/6c0c72f0ecb8/

Log:	More tweaks, preventing a compiler warning

diff --git a/cffi/verifier.py b/cffi/verifier.py
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -332,7 +332,7 @@
         else:
             prnt('  if (LONG_MIN <= (%s) && (%s) <= LONG_MAX)' % (name, name))
             prnt('    o = PyInt_FromLong((long)(%s));' % (name,))
-            prnt('  else if ((%s) < 0)' % (name,))
+            prnt('  else if ((%s) <= 0)' % (name,))
             prnt('    o = PyLong_FromLongLong((long long)(%s));' % (name,))
             prnt('  else')
             prnt('    o = PyLong_FromUnsignedLongLong('
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -242,13 +242,15 @@
     ffi = FFI()
     # use 'static const int', as generally documented, although in this
     # case the 'static' is completely ignored.
-    ffi.cdef("static const int AA, BB, CC;")
+    ffi.cdef("static const int AA, BB, CC, DD;")
     lib = ffi.verify("#define AA 42\n"
                      "#define BB (-43)\n"
-                     "#define CC (22*2)\n")
+                     "#define CC (22*2)\n"
+                     "#define DD ((unsigned int)142)\n")
     assert lib.AA == 42
     assert lib.BB == -43
     assert lib.CC == 44
+    assert lib.DD == 142
 
 def test_global_const_int_size():
     # integer constants: ignore the declared type, always just use the value


More information about the pypy-commit mailing list