tidy-up: prefer ifdef/ifndef for single checks

Closes #18018
This commit is contained in:
Viktor Szakats 2025-07-25 14:31:16 +02:00
parent b2bccdc257
commit 89771d19d5
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
109 changed files with 319 additions and 324 deletions

View file

@ -109,7 +109,7 @@ static void set_ipv6_v6only(curl_socket_t sockfd, int on)
static void tcpnodelay(struct Curl_easy *data, curl_socket_t sockfd)
{
#if defined(TCP_NODELAY)
#ifdef TCP_NODELAY
curl_socklen_t onoff = (curl_socklen_t) 1;
int level = IPPROTO_TCP;
char buffer[STRERROR_LEN];
@ -136,7 +136,7 @@ static void nosigpipe(struct Curl_easy *data,
(void)data;
if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE,
(void *)&onoff, sizeof(onoff)) < 0) {
#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
#ifndef CURL_DISABLE_VERBOSE_STRINGS
char buffer[STRERROR_LEN];
infof(data, "Could not set SO_NOSIGPIPE: %s",
Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
@ -188,9 +188,9 @@ tcpkeepalive(struct Curl_easy *data,
sockfd, SOCKERRNO);
}
else {
#if defined(SIO_KEEPALIVE_VALS) /* Windows */
#ifdef SIO_KEEPALIVE_VALS /* Windows */
/* Windows 10, version 1709 (10.0.16299) and later versions */
#if defined(CURL_WINSOCK_KEEP_SSO)
#ifdef CURL_WINSOCK_KEEP_SSO
optval = curlx_sltosi(data->set.tcp_keepidle);
KEEPALIVE_FACTOR(optval);
if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE,
@ -885,7 +885,7 @@ static CURLcode socket_connect_result(struct Curl_easy *data,
switch(error) {
case SOCKEINPROGRESS:
case SOCKEWOULDBLOCK:
#if defined(EAGAIN)
#ifdef EAGAIN
#if (EAGAIN) != (SOCKEWOULDBLOCK)
/* On some platforms EAGAIN and EWOULDBLOCK are the
* same value, and on others they are different, hence
@ -1237,8 +1237,8 @@ static int do_connect(struct Curl_cfilter *cf, struct Curl_easy *data,
(void)data;
if(is_tcp_fastopen) {
#if defined(CONNECT_DATA_IDEMPOTENT) /* Darwin */
# if defined(HAVE_BUILTIN_AVAILABLE)
#ifdef CONNECT_DATA_IDEMPOTENT /* Darwin */
# ifdef HAVE_BUILTIN_AVAILABLE
/* while connectx function is available since macOS 10.11 / iOS 9,
it did not have the interface declared correctly until
Xcode 9 / macOS SDK 10.13 */
@ -1505,7 +1505,7 @@ static CURLcode cf_socket_send(struct Curl_cfilter *cf, struct Curl_easy *data,
else
*pnwritten = (size_t)nwritten;
#if defined(USE_WINSOCK)
#ifdef USE_WINSOCK
if(!result)
win_update_sndbuf_size(ctx);
#endif