[Python-checkins] cpython: Fix "warning: comparison between signed and unsigned integer expressions"
gregory.p.smith
python-checkins at python.org
Tue Sep 30 09:34:11 CEST 2014
https://hg.python.org/cpython/rev/a404bf4db6a6
changeset: 92651:a404bf4db6a6
user: Gregory P. Smith <greg at krypto.org>
date: Tue Sep 30 00:33:24 2014 -0700
summary:
Fix "warning: comparison between signed and unsigned integer expressions"
-Wsign-compare warnings in unicodeobject.c. These were all a result
of sizeof() being unsigned and being compared to a Py_ssize_t.
Not actual problems.
files:
Objects/unicodeobject.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -816,7 +816,7 @@
assert(_PyUnicode_WSTR(unicode) != NULL);
/* check for integer overflow */
- if (length > PY_SSIZE_T_MAX / sizeof(wchar_t) - 1) {
+ if (length > PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(wchar_t) - 1) {
PyErr_NoMemory();
return -1;
}
@@ -888,7 +888,7 @@
}
/* Ensure we won't overflow the size. */
- if (length > ((PY_SSIZE_T_MAX / sizeof(Py_UNICODE)) - 1)) {
+ if (length > ((PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(Py_UNICODE)) - 1)) {
return (PyUnicodeObject *)PyErr_NoMemory();
}
if (length < 0) {
@@ -2239,7 +2239,7 @@
if (copy_null)
targetlen++;
if (!target) {
- if (PY_SSIZE_T_MAX / sizeof(Py_UCS4) < targetlen) {
+ if (PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(Py_UCS4) < targetlen) {
PyErr_NoMemory();
return NULL;
}
@@ -2852,7 +2852,7 @@
buflen = unicode_aswidechar(unicode, NULL, 0);
if (buflen == -1)
return NULL;
- if (PY_SSIZE_T_MAX / sizeof(wchar_t) < buflen) {
+ if (PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(wchar_t) < buflen) {
PyErr_NoMemory();
return NULL;
}
@@ -15430,7 +15430,7 @@
if (u == NULL)
return NULL;
/* Ensure we won't overflow the size. */
- if (len > ((PY_SSIZE_T_MAX / sizeof(Py_UNICODE)) - 1)) {
+ if (len > ((PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(Py_UNICODE)) - 1)) {
PyErr_NoMemory();
return NULL;
}
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list