[Python-checkins] cpython: Silence VS 2010 signed/unsigned warnings.
martin.v.loewis
python-checkins at python.org
Tue May 15 13:46:19 CEST 2012
http://hg.python.org/cpython/rev/cda2fbbf2a31
changeset: 76944:cda2fbbf2a31
user: Martin v. Löwis <martin at v.loewis.de>
date: Tue May 15 13:45:49 2012 +0200
summary:
Silence VS 2010 signed/unsigned warnings.
files:
Objects/unicodeobject.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -13591,7 +13591,10 @@
c = PyUnicode_READ(fmtkind, fmt, fmtpos++);
if (c < '0' || c > '9')
break;
- if (width > (PY_SSIZE_T_MAX - (c - '0')) / 10) {
+ /* Since c is unsigned, the RHS would end up as unsigned,
+ mixing signed and unsigned comparison. Since c is between
+ '0' and '9', casting to int is safe. */
+ if (width > (PY_SSIZE_T_MAX - ((int)c - '0')) / 10) {
PyErr_SetString(PyExc_ValueError,
"width too big");
goto onError;
@@ -13626,7 +13629,7 @@
c = PyUnicode_READ(fmtkind, fmt, fmtpos++);
if (c < '0' || c > '9')
break;
- if (prec > (INT_MAX - (c - '0')) / 10) {
+ if (prec > (INT_MAX - ((int)c - '0')) / 10) {
PyErr_SetString(PyExc_ValueError,
"prec too big");
goto onError;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list