[Python-checkins] bpo-31474: Fix -Wint-in-bool-context warnings (#3581)

Christian Heimes webhook-mailer at python.org
Fri Sep 15 14:27:26 EDT 2017


https://github.com/python/cpython/commit/fd39e2a6845f33a74fbb0671c434c0d84a5ec2f3
commit: fd39e2a6845f33a74fbb0671c434c0d84a5ec2f3
branch: 2.7
author: Christian Heimes <christian at python.org>
committer: GitHub <noreply at github.com>
date: 2017-09-15T20:27:23+02:00
summary:

bpo-31474: Fix -Wint-in-bool-context warnings (#3581)

Signed-off-by: Christian Heimes <christian at python.org>

files:
A Misc/NEWS.d/next/Build/2017-09-14-19-38-19.bpo-31474.0s_mpD.rst
M Include/pymem.h

diff --git a/Include/pymem.h b/Include/pymem.h
index 10b5bea5eb8..2c239df590d 100644
--- a/Include/pymem.h
+++ b/Include/pymem.h
@@ -72,9 +72,9 @@ PyAPI_FUNC(void) PyMem_Free(void *);
 /* Returns NULL to indicate error if a negative size or size larger than
    Py_ssize_t can represent is supplied.  Helps prevents security holes. */
 #define PyMem_MALLOC(n)		((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \
-				: malloc((n) ? (n) : 1))
+				: malloc(((n) != 0) ? (n) : 1))
 #define PyMem_REALLOC(p, n)	((size_t)(n) > (size_t)PY_SSIZE_T_MAX  ? NULL \
-				: realloc((p), (n) ? (n) : 1))
+				: realloc((p), ((n) != 0) ? (n) : 1))
 #define PyMem_FREE		free
 
 #endif	/* PYMALLOC_DEBUG */
diff --git a/Misc/NEWS.d/next/Build/2017-09-14-19-38-19.bpo-31474.0s_mpD.rst b/Misc/NEWS.d/next/Build/2017-09-14-19-38-19.bpo-31474.0s_mpD.rst
new file mode 100644
index 00000000000..41505aa4f7e
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2017-09-14-19-38-19.bpo-31474.0s_mpD.rst
@@ -0,0 +1 @@
+Fix -Wint-in-bool-context warnings in PyMem_MALLOC and PyMem_REALLOC macros



More information about the Python-checkins mailing list