[Python-checkins] cpython: Fixed few compiler warnings.

serhiy.storchaka python-checkins at python.org
Mon Feb 16 08:41:49 CET 2015


https://hg.python.org/cpython/rev/f402a6511559
changeset:   94649:f402a6511559
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Mon Feb 16 09:40:12 2015 +0200
summary:
  Fixed few compiler warnings.

files:
  Modules/cjkcodecs/_codecs_iso2022.c |  7 +++----
  Modules/faulthandler.c              |  2 +-
  Python/ceval_gil.h                  |  4 ++--
  Python/pylifecycle.c                |  2 +-
  Python/pystate.c                    |  4 ++--
  5 files changed, 9 insertions(+), 10 deletions(-)


diff --git a/Modules/cjkcodecs/_codecs_iso2022.c b/Modules/cjkcodecs/_codecs_iso2022.c
--- a/Modules/cjkcodecs/_codecs_iso2022.c
+++ b/Modules/cjkcodecs/_codecs_iso2022.c
@@ -292,7 +292,7 @@
                   const unsigned char **inbuf, Py_ssize_t *inleft)
 {
     unsigned char charset, designation;
-    Py_ssize_t i, esclen;
+    Py_ssize_t i, esclen = 0;
 
     for (i = 1;i < MAX_ESCSEQLEN;i++) {
         if (i >= *inleft)
@@ -307,10 +307,9 @@
         }
     }
 
-    if (i >= MAX_ESCSEQLEN)
+    switch (esclen) {
+    case 0:
         return 1; /* unterminated escape sequence */
-
-    switch (esclen) {
     case 3:
         if (INBYTE2 == '$') {
             charset = INBYTE3 | CHARSET_DBCS;
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -458,7 +458,7 @@
         assert(st == PY_LOCK_FAILURE);
 
         /* get the thread holding the GIL, NULL if no thread hold the GIL */
-        current = _Py_atomic_load_relaxed(&_PyThreadState_Current);
+        current = (PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current);
 
         write(thread.fd, thread.header, (int)thread.header_len);
 
diff --git a/Python/ceval_gil.h b/Python/ceval_gil.h
--- a/Python/ceval_gil.h
+++ b/Python/ceval_gil.h
@@ -191,7 +191,7 @@
     if (_Py_atomic_load_relaxed(&gil_drop_request) && tstate != NULL) {
         MUTEX_LOCK(switch_mutex);
         /* Not switched yet => wait */
-        if (_Py_atomic_load_relaxed(&gil_last_holder) == tstate) {
+        if ((PyThreadState*)_Py_atomic_load_relaxed(&gil_last_holder) == tstate) {
         RESET_GIL_DROP_REQUEST();
             /* NOTE: if COND_WAIT does not atomically start waiting when
                releasing the mutex, another thread can run through, take
@@ -239,7 +239,7 @@
     _Py_atomic_store_relaxed(&gil_locked, 1);
     _Py_ANNOTATE_RWLOCK_ACQUIRED(&gil_locked, /*is_write=*/1);
 
-    if (tstate != _Py_atomic_load_relaxed(&gil_last_holder)) {
+    if (tstate != (PyThreadState*)_Py_atomic_load_relaxed(&gil_last_holder)) {
         _Py_atomic_store_relaxed(&gil_last_holder, tstate);
         ++gil_switch_number;
     }
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1258,7 +1258,7 @@
         PyErr_PrintEx(0);
     }
     else {
-        tstate = _Py_atomic_load_relaxed(&_PyThreadState_Current);
+        tstate = (PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current);
         if (tstate != NULL) {
             fputc('\n', stderr);
             fflush(stderr);
diff --git a/Python/pystate.c b/Python/pystate.c
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -403,7 +403,7 @@
 void
 PyThreadState_Delete(PyThreadState *tstate)
 {
-    if (tstate == _Py_atomic_load_relaxed(&_PyThreadState_Current))
+    if (tstate == (PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
         Py_FatalError("PyThreadState_Delete: tstate is still current");
 #ifdef WITH_THREAD
     if (autoInterpreterState && PyThread_get_key_value(autoTLSkey) == tstate)
@@ -662,7 +662,7 @@
 {
     /* Must be the tstate for this thread */
     assert(PyGILState_GetThisThreadState()==tstate);
-    return tstate == _Py_atomic_load_relaxed(&_PyThreadState_Current);
+    return tstate == (PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current);
 }
 
 /* Internal initialization/finalization functions called by

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list