[prev in list] [next in list] [prev in thread] [next in thread] 

List:       subversion-commits
Subject:    svn commit: r1598174 - /subversion/trunk/subversion/bindings/swig/core.i
From:       breser () apache ! org
Date:       2014-05-28 23:43:36
Message-ID: 20140528234336.B849B2388999 () eris ! apache ! org
[Download RAW message or body]

Author: breser
Date: Wed May 28 23:43:36 2014
New Revision: 1598174

URL: http://svn.apache.org/r1598174
Log:
swig-py: Fix a compiler warning about dead code.

* subversion/bindings/swig/core.i: For the typemap to handle buffer/len in
    args retrieve the length as an unsigned long and remove the pointless check
    for less than 0.  The temp variable is an apr_size_t which is unsigned and
    as such the test will never fail.  This shifts the bounds checking to
    Python's conversion code.  Unfortunately, in the PyInt case there's no way
    to do the bounds checking, but it's not like our existing bounds checking
    worked anyway.

Modified:
    subversion/trunk/subversion/bindings/swig/core.i

Modified: subversion/trunk/subversion/bindings/swig/core.i
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/core.i?rev=1598174&r1=1598173&r2=1598174&view=diff
 ==============================================================================
--- subversion/trunk/subversion/bindings/swig/core.i (original)
+++ subversion/trunk/subversion/bindings/swig/core.i Wed May 28 23:43:36 2014
@@ -379,21 +379,21 @@
 #ifdef SWIGPYTHON
 %typemap(in) (char *buffer, apr_size_t *len) ($*2_type temp) {
     if (PyLong_Check($input)) {
-        temp = PyLong_AsLong($input);
+        temp = PyLong_AsUnsignedLong($input);
     }
     else if (PyInt_Check($input)) {
-        temp = PyInt_AsLong($input);
+        /* wish there was a PyInt_AsUnsignedLong but there isn't
+           the mask version doesn't do bounds checking for us.
+           I can't see a good way to do the bounds checking ourselves
+           so just stick our head in the sand.  With Python3 this
+           problem goes away because PyInt is gone anyway. */
+        temp = PyInt_AsUnsignedLongMask($input);
     }
     else {
         PyErr_SetString(PyExc_TypeError,
                         "expecting an integer for the buffer size");
         SWIG_fail;
     }
-    if (temp < 0) {
-        PyErr_SetString(PyExc_ValueError,
-                        "buffer size must be a positive integer");
-        SWIG_fail;
-    }
     $1 = malloc(temp);
     $2 = ($2_ltype)&temp;
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic