From 91a3b9e4f08a5e1325642c68543495c32fc853f9 Mon Sep 17 00:00:00 2001 From: Matthias Klose Date: Sun, 5 Apr 2009 21:19:13 +0000 Subject: Issue #1113244: Py_XINCREF, Py_DECREF, Py_XDECREF: Add `do { ... } while (0)' to avoid compiler warnings. --- Include/object.h | 4 ++-- Misc/NEWS | 3 ++- Modules/readline.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Include/object.h b/Include/object.h index 3d898f9..1bc13e7 100644 --- a/Include/object.h +++ b/Include/object.h @@ -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 diff --git a/Misc/NEWS b/Misc/NEWS index b8d3883..e9ee104 100644 --- 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 ------- diff --git a/Modules/readline.c b/Modules/readline.c index f5a54bc..d09f09c 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -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: -- cgit v0.12