]> granicus.if.org Git - python/commitdiff
Issue #1113244: Py_XINCREF, Py_DECREF, Py_XDECREF: Add `do { ... } while (0)'
authorMatthias Klose <doko@ubuntu.com>
Sun, 5 Apr 2009 21:19:13 +0000 (21:19 +0000)
committerMatthias Klose <doko@ubuntu.com>
Sun, 5 Apr 2009 21:19:13 +0000 (21:19 +0000)
to avoid compiler warnings.

Include/object.h
Misc/NEWS
Modules/readline.c

index 3d898f905d179acf42b1c2afef33139b641ad03c..1bc13e7c2af4e97f566d86e2718aa44a136e66a1 100644 (file)
@@ -801,8 +801,8 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
         } while (0)
 
 /* Macros to use in case the object pointer may be NULL: */
-#define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op)
-#define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op)
+#define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0)
+#define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0)
 
 /*
 These are provided as conveniences to Python runtime embedders, so that
index b8d3883a86f010b305cc78e69a50bae330546b23..e9ee104a5d31fb1c8df6ef5f71251833246ee7b3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -207,7 +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.
+- Issue #1113244: Py_XINCREF, Py_DECREF, Py_XDECREF: Add `do { ... } while (0)'
+  to avoid compiler warnings.
 
 Library
 -------
index f5a54bc08f6964fe49c96e5328be5535dc2ddf51..d09f09c7311c3296adfd1290a87adad61ae3ee35 100644 (file)
@@ -694,13 +694,13 @@ on_completion_display_matches_hook(char **matches,
        r = PyObject_CallFunction(completion_display_matches_hook,
                                  "sOi", matches[0], m, max_length);
 
-       Py_DECREF(m), m=NULL;
+       Py_DECREF(m); m=NULL;
        
        if (r == NULL ||
            (r != Py_None && PyInt_AsLong(r) == -1 && PyErr_Occurred())) {
                goto error;
        }
-       Py_XDECREF(r), r=NULL;
+       Py_XDECREF(r); r=NULL;
 
        if (0) {
        error: