[Xcb] [PATCH xpyb 08/10] module.c: Delete explicit comparison with NULL

Tapasweni Pathak tapaswenipathak at gmail.com
Sun Oct 12 21:50:14 PDT 2014


if (pointer == NULL) is functionally equivalent to
if (!pointer).

Using the second will make it a bit obvious that there is a
pointer involved and not an integer or something.

This patch deletes explicit comaprison with NULL in module.c file.

Signed-off-by: Tapasweni Pathak <tapaswenipathak at gmail.com>
---
 src/module.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/module.c b/src/module.c
index 18f0228..8e3a650 100644
--- a/src/module.c
+++ b/src/module.c
@@ -42,7 +42,7 @@ xpyb_connect(PyObject *self, PyObject *args, PyObject *kw)
 {
     xpybConn *conn = PyObject_New(xpybConn, &xpybConn_type);

-    if (conn == NULL)
+    if (!conn)
 	return NULL;

     if(xpybConn_init(conn, args, kw) < 0)
@@ -59,7 +59,7 @@ xpyb_wrap(PyObject *self, PyObject *args)
     xpybConn *conn;

     /* Make sure core was set. */
-    if (xpybModule_core == NULL) {
+    if (!xpybModule_core) {
 	PyErr_SetString(xpybExcept_base, "No core protocol object has been set.  Did you import xcb.xproto?");
 	return NULL;
     }
@@ -102,7 +102,7 @@ xpyb_add_core(PyObject *self, PyObject *args)
     PyTypeObject *value, *setup;
     PyObject *events, *errors;

-    if (xpybModule_core != NULL)
+    if (xpybModule_core)
 	Py_RETURN_NONE;

     if (!PyArg_ParseTuple(args, "O!O!O!O!", &PyType_Type, &value, &PyType_Type, &setup,
@@ -161,7 +161,7 @@ xpyb_resize_obj(PyObject *self, PyObject *args)
 	return NULL;

     buf = PyBuffer_FromObject(obj->buf, 0, size);
-    if (buf == NULL)
+    if (!buf)
 	return NULL;

     Py_CLEAR(obj->buf);
@@ -245,15 +245,15 @@ initxcb(void)
 {
     /* Create module object */
     PyObject *m = Py_InitModule3("xcb", XCBMethods, "XCB Python Binding.");
-    if (m == NULL)
+    if (!m)
 	return;

     /* Create other internal objects */
-    if ((xpybModule_extdict = PyDict_New()) == NULL)
+    if (!(xpybModule_extdict = PyDict_New()))
 	return;
-    if ((xpybModule_ext_events = PyDict_New()) == NULL)
+    if (!(xpybModule_ext_events = PyDict_New()))
 	return;
-    if ((xpybModule_ext_errors = PyDict_New()) == NULL)
+    if (!(xpybModule_ext_errors = PyDict_New()))
 	return;

     /* Add integer constants */
--
1.7.9.5



More information about the Xcb mailing list