From 228b12edcce49649d6befa3c03dbcefd5a22ae76 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 23 Jan 2017 09:47:21 +0200 Subject: Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever possible. Patch is writen with Coccinelle. --- Modules/socketmodule.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'Modules/socketmodule.c') diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 274769d6b0..8d0f9e6df8 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1218,8 +1218,7 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto) { if (addrlen == 0) { /* No address -- may be recvfrom() from known socket */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } switch (addr->sa_family) { @@ -2540,8 +2539,7 @@ static PyObject * sock_gettimeout(PySocketSockObject *s) { if (s->sock_timeout < 0) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { double seconds = _PyTime_AsSecondsDouble(s->sock_timeout); @@ -2701,8 +2699,7 @@ sock_bind(PySocketSockObject *s, PyObject *addro) Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(bind_doc, @@ -2738,8 +2735,7 @@ sock_close(PySocketSockObject *s) return s->errorhandler(); } } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(close_doc, @@ -2996,8 +2992,7 @@ sock_listen(PySocketSockObject *s, PyObject *args) Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(listen_doc, @@ -4363,8 +4358,7 @@ sock_shutdown(PySocketSockObject *s, PyObject *arg) Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(shutdown_doc, @@ -6196,8 +6190,7 @@ static PyObject * socket_getdefaulttimeout(PyObject *self) { if (defaulttimeout < 0) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { double seconds = _PyTime_AsSecondsDouble(defaulttimeout); @@ -6222,8 +6215,7 @@ socket_setdefaulttimeout(PyObject *self, PyObject *arg) defaulttimeout = timeout; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(setdefaulttimeout_doc, -- cgit v1.2.1