]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
- Py_DECREF: Add `do { ... } while (0)' to avoid compiler warnings.
authorMatthias Klose <doko@ubuntu.com>
Sat, 4 Apr 2009 15:51:23 +0000 (15:51 +0000)
committerMatthias Klose <doko@ubuntu.com>
Sat, 4 Apr 2009 15:51:23 +0000 (15:51 +0000)
Include/object.h
Misc/NEWS

index cfca64f9ab6e58d4d368e741f9aacdc732936ade..fb5376a2ed9796072a3d6ab48acc170f907ea972 100644 (file)
@@ -749,11 +749,13 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
        ((PyObject*)(op))->ob_refcnt++)
 
 #define Py_DECREF(op)                                  \
-       if (_Py_DEC_REFTOTAL  _Py_REF_DEBUG_COMMA       \
-           --((PyObject*)(op))->ob_refcnt != 0)                \
-               _Py_CHECK_REFCNT(op)                    \
-       else                                            \
-               _Py_Dealloc((PyObject *)(op))
+       do {                                            \
+           if (_Py_DEC_REFTOTAL  _Py_REF_DEBUG_COMMA   \
+               --((PyObject*)(op))->ob_refcnt != 0)    \
+                   _Py_CHECK_REFCNT(op)                \
+           else                                        \
+               _Py_Dealloc((PyObject *)(op))           \
+        } while (0)
 
 /* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
  * and tp_dealloc implementatons.
index db86b517b24fd1c59aa79076716d00113087759a..f254bfd5d382e0a5059c51446a5b9a0693027104 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -207,6 +207,8 @@ Core and Builtins
 - Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
   short file names.
 
+- Py_DECREF: Add `do { ... } while (0)' to avoid compiler warnings.
+
 Library
 -------