[Xcb] [PATCH xpyb 07/10] list.c: Delete explicit comparison with NULL

Tapasweni Pathak tapaswenipathak at gmail.com
Sun Oct 12 21:49:53 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 list.c file.

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

diff --git a/src/list.c b/src/list.c
index 19b2551..0e2d478 100644
--- a/src/list.c
+++ b/src/list.c
@@ -61,7 +61,7 @@ xpybList_init(xpybList *self, PyObject *args, PyObject *kw)
 	return -1;

     self->list = PyList_New(0);
-    if (self->list == NULL)
+    if (!self->list)
 	return -1;

     if (PyObject_AsReadBuffer(parent, (const void **)&data, &datalen) < 0)
@@ -77,21 +77,21 @@ xpybList_init(xpybList *self, PyObject *args, PyObject *kw)
     for (i = 0; i < length; i++) {
 	if (PyString_CheckExact(type)) {
 	    obj = xpybList_build(type, length, data + cur);
-	    if (obj == NULL)
+	    if (!obj)
 		return -1;
 	    cur += size;
 	} else if (size > 0) {
 	    arglist = Py_BuildValue("(Onn)", parent, cur, size);
 	    obj = PyEval_CallObject(type, arglist);
 	    Py_DECREF(arglist);
-	    if (obj == NULL)
+	    if (!obj)
 		return -1;
 	    cur += size;
 	} else {
 	    arglist = Py_BuildValue("(On)", parent, cur);
 	    obj = PyEval_CallObject(type, arglist);
 	    Py_DECREF(arglist);
-	    if (obj == NULL)
+	    if (!obj)
 		return -1;
 	    datalen = PySequence_Size(obj);
 	    if (datalen < 0)
@@ -105,7 +105,7 @@ xpybList_init(xpybList *self, PyObject *args, PyObject *kw)
     }

     self->buf = PyBuffer_FromObject(parent, offset, cur - offset);
-    if (self->buf == NULL)
+    if (!self->buf)
 	return -1;

     return 0;
--
1.7.9.5



More information about the Xcb mailing list