inotify: _inotify.c: bugfix: remove_watch has to return PyNone on success
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Thu, 27 Aug 2009 11:55:21 +0200
changeset 9428 5d6659cfaa06
parent 9427 d37c0f4e8f48
child 9429 d8143769e1d4
inotify: _inotify.c: bugfix: remove_watch has to return PyNone on success We are not currently using that API function in inotify, hence the reason for the "silent" bug. But returning NULL here causes the interpreter to crash. Let's keep code clean for reusers :) The whole "bail" logic was unneeded here.
hgext/inotify/linux/_inotify.c
--- a/hgext/inotify/linux/_inotify.c	Thu Aug 27 14:15:04 2009 +0200
+++ b/hgext/inotify/linux/_inotify.c	Thu Aug 27 11:55:21 2009 +0200
@@ -106,13 +106,12 @@
 
 static PyObject *remove_watch(PyObject *self, PyObject *args)
 {
-    PyObject *ret = NULL;
     uint32_t wd;
     int fd;
     int r;
 
     if (!PyArg_ParseTuple(args, "iI:remove_watch", &fd, &wd))
-	goto bail;
+	return NULL;
 
     Py_BEGIN_ALLOW_THREADS
     r = inotify_rm_watch(fd, wd);
@@ -120,18 +119,11 @@
 
     if (r == -1) {
 	PyErr_SetFromErrno(PyExc_OSError);
-	goto bail;
+	return NULL;
     }
 
     Py_INCREF(Py_None);
-
-    goto done;
-
-bail:
-    Py_CLEAR(ret);
-
-done:
-    return ret;
+    return Py_None;
 }
 
 PyDoc_STRVAR(