summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-08-17 20:20:00 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-08-17 20:20:00 (GMT)
commit049e509a9f87d1f82ae0ebfe21c226f37ce9fbdb (patch)
tree96885f696a33000548163e8b4bab6415dd842dde /Modules
parentdaca3d7e9b48badf02521df1b729ddd2733b2d77 (diff)
downloadcpython-049e509a9f87d1f82ae0ebfe21c226f37ce9fbdb.zip
cpython-049e509a9f87d1f82ae0ebfe21c226f37ce9fbdb.tar.gz
cpython-049e509a9f87d1f82ae0ebfe21c226f37ce9fbdb.tar.bz2
Issue #22207: Fix "comparison between signed and unsigned integers" warning in
test checking for integer overflow on Py_ssize_t type: cast explicitly to size_t.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_codecsmodule.c2
-rw-r--r--Modules/_lzmamodule.c4
-rw-r--r--Modules/_pickle.c5
-rw-r--r--Modules/fcntlmodule.c2
-rw-r--r--Modules/mathmodule.c2
5 files changed, 8 insertions, 7 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 1b21300..ac25998 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -699,7 +699,7 @@ unicode_internal_encode(PyObject *self,
u = PyUnicode_AsUnicodeAndSize(obj, &len);
if (u == NULL)
return NULL;
- if (len > PY_SSIZE_T_MAX / sizeof(Py_UNICODE))
+ if ((size_t)len > (size_t)PY_SSIZE_T_MAX / sizeof(Py_UNICODE))
return PyErr_NoMemory();
size = len * sizeof(Py_UNICODE);
return codec_tuple(PyBytes_FromStringAndSize((const char*)u, size),
diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c
index c43676a..dfb95fa 100644
--- a/Modules/_lzmamodule.c
+++ b/Modules/_lzmamodule.c
@@ -533,7 +533,7 @@ compress(Compressor *c, uint8_t *data, size_t len, lzma_action action)
c->lzs.avail_out = PyBytes_GET_SIZE(result) - data_size;
}
}
- if (data_size != PyBytes_GET_SIZE(result))
+ if (data_size != (size_t)PyBytes_GET_SIZE(result))
if (_PyBytes_Resize(&result, data_size) == -1)
goto error;
return result;
@@ -931,7 +931,7 @@ decompress(Decompressor *d, uint8_t *data, size_t len)
d->lzs.avail_out = PyBytes_GET_SIZE(result) - data_size;
}
}
- if (data_size != PyBytes_GET_SIZE(result))
+ if (data_size != (size_t)PyBytes_GET_SIZE(result))
if (_PyBytes_Resize(&result, data_size) == -1)
goto error;
return result;
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 1c15190..ba9ba99 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -2052,7 +2052,8 @@ raw_unicode_escape(PyObject *obj)
{
PyObject *repr;
char *p;
- Py_ssize_t i, size, expandsize;
+ Py_ssize_t i, size;
+ size_t expandsize;
void *data;
unsigned int kind;
@@ -2067,7 +2068,7 @@ raw_unicode_escape(PyObject *obj)
else
expandsize = 6;
- if (size > PY_SSIZE_T_MAX / expandsize)
+ if ((size_t)size > (size_t)PY_SSIZE_T_MAX / expandsize)
return PyErr_NoMemory();
repr = PyBytes_FromStringAndSize(NULL, expandsize * size);
if (repr == NULL)
diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c
index cf0ac19..56e4021 100644
--- a/Modules/fcntlmodule.c
+++ b/Modules/fcntlmodule.c
@@ -42,7 +42,7 @@ fcntl_fcntl(PyObject *self, PyObject *args)
if (PyArg_ParseTuple(args, "O&is#:fcntl",
conv_descriptor, &fd, &code, &str, &len)) {
- if (len > sizeof buf) {
+ if ((size_t)len > sizeof buf) {
PyErr_SetString(PyExc_ValueError,
"fcntl string arg too long");
return NULL;
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 7f525ea..bce3799 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -1010,7 +1010,7 @@ _fsum_realloc(double **p_ptr, Py_ssize_t n,
Py_ssize_t m = *m_ptr;
m += m; /* double */
- if (n < m && m < (PY_SSIZE_T_MAX / sizeof(double))) {
+ if (n < m && (size_t)m < ((size_t)PY_SSIZE_T_MAX / sizeof(double))) {
double *p = *p_ptr;
if (p == ps) {
v = PyMem_Malloc(sizeof(double) * m);