]> granicus.if.org Git - python/commitdiff
Issue #23618: Cleanup internal_connect() in socketmodule.c
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 31 Mar 2015 19:23:10 +0000 (21:23 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 31 Mar 2015 19:23:10 +0000 (21:23 +0200)
On Windows, it looks like using the C type socklen_t for getsockopt() (instead
of int) is fine, it was already used in socket.getsockopt().

Modules/socketmodule.c

index ab3e913dbc80aabc1d995a84eb51eae206509548..211e77bb7b7d79e0d86aef0c2f7aae37c2f35d66 100644 (file)
@@ -2485,7 +2485,7 @@ internal_connect(PySocketSockObject *s, struct sockaddr *addr, int addrlen,
         else if (timeout == 0) {
             socklen_t res_size = sizeof res;
             if (!getsockopt(s->sock_fd, SOL_SOCKET, SO_ERROR,
-                            (char*)&res, &res_size)) {
+                            (void *)&res, &res_size)) {
                 if (res == EISCONN)
                     res = 0;
                 err = res;
@@ -2533,8 +2533,6 @@ sock_connect(PySocketSockObject *s, PyObject *addro)
         return NULL;
     if (res != 0) {
 #ifdef MS_WINDOWS
-        /* getsockopt also clears WSAGetLastError,
-           so reset it back. */
         WSASetLastError(res);
 #else
         errno = res;