From b0ccea93587b613b655a84dd88c5c9bb0e826b47 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 12 Jun 2026 16:55:47 +0200 Subject: [PATCH] replace switch cases with the new macro --- lib/cf-socket.c | 31 ++++++++++--------------------- lib/vquic/vquic.c | 8 +++----- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/lib/cf-socket.c b/lib/cf-socket.c index 6d1cb9e892..4a21c00262 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -939,30 +939,19 @@ static bool verifyconnect(curl_socket_t sockfd, int *error) static CURLcode socket_connect_result(struct Curl_easy *data, const char *ipaddress, int error) { - switch(error) { - case SOCKEINPROGRESS: - case SOCKEWOULDBLOCK: -#if !defined(USE_WINSOCK) && EAGAIN != SOCKEWOULDBLOCK - /* On some platforms EAGAIN and EWOULDBLOCK are the - * same value, and on others they are different, hence - * the odd #if - */ - case EAGAIN: -#endif + if(SOCK_EWOULDBLOCK_EAGAIN(error) || error == SOCKEINPROGRESS) return CURLE_OK; - default: - /* unknown error, fallthrough and try another address! */ - { - VERBOSE(char buffer[STRERROR_LEN]); - infof(data, "Immediate connect fail for %s: %s", ipaddress, - curlx_strerror(error, buffer, sizeof(buffer))); - NOVERBOSE((void)ipaddress); - } - data->state.os_errno = error; - /* connect failed */ - return CURLE_COULDNT_CONNECT; + /* unknown error, fallthrough and try another address! */ + { + VERBOSE(char buffer[STRERROR_LEN]); + infof(data, "Immediate connect fail for %s: %s", ipaddress, + curlx_strerror(error, buffer, sizeof(buffer))); + NOVERBOSE((void)ipaddress); } + data->state.os_errno = error; + /* connect failed */ + return CURLE_COULDNT_CONNECT; } struct cf_socket_ctx { diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c index c8bf9a086c..73279e644b 100644 --- a/lib/vquic/vquic.c +++ b/lib/vquic/vquic.c @@ -165,12 +165,10 @@ static CURLcode do_sendmsg(struct Curl_cfilter *cf, ; if(!curlx_sztouz(rv, psent)) { - switch(SOCKERRNO) { - case SOCKEWOULDBLOCK: -#if !defined(USE_WINSOCK) && EAGAIN != SOCKEWOULDBLOCK - case EAGAIN: -#endif + int err = SOCKERRNO; + if(SOCK_EWOULDBLOCK_EAGAIN(err)) return CURLE_AGAIN; + switch(err) { case SOCKEMSGSIZE: /* UDP datagram is too large; caused by PMTUD. Let it be lost. */ *psent = pktlen;