From: Victor Stinner Date: Sat, 26 Jul 2014 12:47:56 +0000 (+0200) Subject: socketmodule.c: backport INVALID_SOCKET from Python 3.5 to simplify the code X-Git-Tag: v2.7.9rc1~338 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=465db3c69ad69df013149eaecffc3ac719b177ca;p=thirdparty%2FPython%2Fcpython.git socketmodule.c: backport INVALID_SOCKET from Python 3.5 to simplify the code --- diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 880f31165a9b..130b6b3c8c49 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -94,6 +94,10 @@ Local naming conventions: #include "structmember.h" #include "timefuncs.h" +#ifndef INVALID_SOCKET /* MS defines this */ +#define INVALID_SOCKET (-1) +#endif + #undef MAX #define MAX(x, y) ((x) < (y) ? (y) : (x)) @@ -1705,11 +1709,7 @@ sock_accept(PySocketSockObject *s) return NULL; memset(&addrbuf, 0, addrlen); -#ifdef MS_WINDOWS newfd = INVALID_SOCKET; -#else - newfd = -1; -#endif if (!IS_SELECTABLE(s)) return select_error(); @@ -1727,11 +1727,7 @@ sock_accept(PySocketSockObject *s) } END_SELECT_LOOP(s) -#ifdef MS_WINDOWS if (newfd == INVALID_SOCKET) -#else - if (newfd < 0) -#endif return s->errorhandler(); /* Create the new object with unspecified family, @@ -3185,12 +3181,7 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds) fd = socket(family, type, proto); Py_END_ALLOW_THREADS -#ifdef MS_WINDOWS - if (fd == INVALID_SOCKET) -#else - if (fd < 0) -#endif - { + if (fd == INVALID_SOCKET) { set_error(); return -1; }