@@ -2530,7 +2530,6 @@ _ssl__SSLSocket_sendfile_impl(PySSLSocket *self, int fd, Py_off_t offset,
25302530    Py_ssize_t  retval ;
25312531    int  sockstate ;
25322532    _PySSLError  err ;
2533-     int  nonblocking ;
25342533    PySocketSockObject  * sock  =  GET_SOCKET (self );
25352534    PyTime_t  timeout , deadline  =  0 ;
25362535    int  has_timeout ;
@@ -2547,7 +2546,7 @@ _ssl__SSLSocket_sendfile_impl(PySSLSocket *self, int fd, Py_off_t offset,
25472546
25482547    if  (sock  !=  NULL ) {
25492548        /* just in case the blocking state of the socket has been changed */ 
2550-         nonblocking  =  (sock -> sock_timeout  >= 0 );
2549+         int   nonblocking  =  (sock -> sock_timeout  >= 0 );
25512550        BIO_set_nbio (SSL_get_rbio (self -> ssl ), nonblocking );
25522551        BIO_set_nbio (SSL_get_wbio (self -> ssl ), nonblocking );
25532552    }
@@ -2559,18 +2558,19 @@ _ssl__SSLSocket_sendfile_impl(PySSLSocket *self, int fd, Py_off_t offset,
25592558    }
25602559
25612560    sockstate  =  PySSL_select (sock , 1 , timeout );
2562-     if  (sockstate  ==  SOCKET_HAS_TIMED_OUT ) {
2563-         PyErr_SetString (PyExc_TimeoutError ,
2564-                         "The write operation timed out" );
2565-         goto error ;
2566-     } else  if  (sockstate  ==  SOCKET_HAS_BEEN_CLOSED ) {
2567-         PyErr_SetString (get_state_sock (self )-> PySSLErrorObject ,
2568-                         "Underlying socket has been closed." );
2569-         goto error ;
2570-     } else  if  (sockstate  ==  SOCKET_TOO_LARGE_FOR_SELECT ) {
2571-         PyErr_SetString (get_state_sock (self )-> PySSLErrorObject ,
2572-                         "Underlying socket too large for select()." );
2573-         goto error ;
2561+     switch  (sockstate ) {
2562+         case  SOCKET_HAS_TIMED_OUT :
2563+             PyErr_SetString (PyExc_TimeoutError ,
2564+                             "The write operation timed out" );
2565+             goto error ;
2566+         case  SOCKET_HAS_BEEN_CLOSED :
2567+             PyErr_SetString (get_state_sock (self )-> PySSLErrorObject ,
2568+                             "Underlying socket has been closed." );
2569+             goto error ;
2570+         case  SOCKET_TOO_LARGE_FOR_SELECT :
2571+             PyErr_SetString (get_state_sock (self )-> PySSLErrorObject ,
2572+                             "Underlying socket too large for select()." );
2573+             goto error ;
25742574    }
25752575
25762576    do  {
@@ -2588,23 +2588,29 @@ _ssl__SSLSocket_sendfile_impl(PySSLSocket *self, int fd, Py_off_t offset,
25882588            timeout  =  _PyDeadline_Get (deadline );
25892589        }
25902590
2591-         if  (err .ssl  ==  SSL_ERROR_WANT_READ ) {
2592-             sockstate  =  PySSL_select (sock , 0 , timeout );
2593-         } else  if  (err .ssl  ==  SSL_ERROR_WANT_WRITE ) {
2594-             sockstate  =  PySSL_select (sock , 1 , timeout );
2595-         } else  {
2596-             sockstate  =  SOCKET_OPERATION_OK ;
2591+         switch  (err .ssl ) {
2592+             case  SSL_ERROR_WANT_READ :
2593+                 sockstate  =  PySSL_select (sock , 0 , timeout );
2594+                 break ;
2595+             case  SSL_ERROR_WANT_WRITE :
2596+                 sockstate  =  PySSL_select (sock , 1 , timeout );
2597+                 break ;
2598+             default :
2599+                 sockstate  =  SOCKET_OPERATION_OK ;
2600+                 break ;
25972601        }
25982602
25992603        if  (sockstate  ==  SOCKET_HAS_TIMED_OUT ) {
26002604            PyErr_SetString (PyExc_TimeoutError ,
26012605                            "The sendfile operation timed out" );
26022606            goto error ;
2603-         } else  if  (sockstate  ==  SOCKET_HAS_BEEN_CLOSED ) {
2607+         }
2608+         else  if  (sockstate  ==  SOCKET_HAS_BEEN_CLOSED ) {
26042609            PyErr_SetString (get_state_sock (self )-> PySSLErrorObject ,
26052610                            "Underlying socket has been closed." );
26062611            goto error ;
2607-         } else  if  (sockstate  ==  SOCKET_IS_NONBLOCKING ) {
2612+         }
2613+         else  if  (sockstate  ==  SOCKET_IS_NONBLOCKING ) {
26082614            break ;
26092615        }
26102616    } while  (err .ssl  ==  SSL_ERROR_WANT_READ  || 
0 commit comments