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

@ -51,7 +51,7 @@ AP_DECLARE_MODULE(curltest) =
NULL, /* func to merge per server config */
NULL, /* command handlers */
curltest_hooks,
#if defined(AP_MODULE_FLAG_NONE)
#ifdef AP_MODULE_FLAG_NONE
AP_MODULE_FLAG_ALWAYS_MERGE
#endif
};

View file

@ -64,7 +64,7 @@ static int sockopt_cb(void *clientp,
return CURL_SOCKOPT_ALREADY_CONNECTED;
}
#if defined(__AMIGA__)
#ifdef __AMIGA__
#define my_inet_pton(x,y,z) inet_pton(x,(unsigned char *)y,z)
#else
#define my_inet_pton(x,y,z) inet_pton(x,y,z)

View file

@ -25,7 +25,7 @@
#include "memdebug.h"
#if defined(USE_THREADS_POSIX)
#ifdef USE_THREADS_POSIX
#include <pthread.h>
#endif

View file

@ -471,7 +471,7 @@ test_cleanup:
return res;
}
#else /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */
#else /* HAVE_GETRLIMIT && HAVE_SETRLIMIT */
static CURLcode test_lib518(char *URL)
{
@ -480,4 +480,4 @@ static CURLcode test_lib518(char *URL)
return TEST_ERR_MAJOR_BAD; /* skip test */
}
#endif /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */
#endif /* HAVE_GETRLIMIT && HAVE_SETRLIMIT */

View file

@ -235,12 +235,12 @@ static void t530_updateFdSet(struct t530_Sockets *sockets, fd_set* fdset,
{
int i;
for(i = 0; i < sockets->count; ++i) {
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockets->sockets[i], fdset);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(*maxFd < sockets->sockets[i] + 1) {

View file

@ -485,7 +485,7 @@ test_cleanup:
return res;
}
#else /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */
#else /* HAVE_GETRLIMIT && HAVE_SETRLIMIT */
static CURLcode test_lib537(char *URL)
{
@ -494,4 +494,4 @@ static CURLcode test_lib537(char *URL)
return TEST_ERR_MAJOR_BAD; /* skip test */
}
#endif /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */
#endif /* HAVE_GETRLIMIT && HAVE_SETRLIMIT */

View file

@ -182,12 +182,12 @@ static void t582_updateFdSet(struct t582_Sockets *sockets, fd_set* fdset,
{
int i;
for(i = 0; i < sockets->count; ++i) {
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockets->sockets[i], fdset);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(*maxFd < sockets->sockets[i] + 1) {

View file

@ -666,12 +666,12 @@ static bool mqttd_incoming(curl_socket_t listenfd)
FD_ZERO(&fds_err);
/* there's always a socket to wait for */
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif

View file

@ -42,7 +42,7 @@ static int test_resolve(int argc, char *argv[])
while(argc > arg) {
if(!strcmp("--version", argv[arg])) {
printf("resolve IPv4%s\n",
#if defined(CURLRES_IPV6)
#ifdef CURLRES_IPV6
"/IPv6"
#else
""
@ -51,7 +51,7 @@ static int test_resolve(int argc, char *argv[])
return 0;
}
else if(!strcmp("--ipv6", argv[arg])) {
#if defined(CURLRES_IPV6)
#ifdef CURLRES_IPV6
ipv_inuse = "IPv6";
use_ipv6 = TRUE;
arg++;
@ -63,7 +63,7 @@ static int test_resolve(int argc, char *argv[])
else if(!strcmp("--ipv4", argv[arg])) {
/* for completeness, we support this option as well */
ipv_inuse = "IPv4";
#if defined(CURLRES_IPV6)
#ifdef CURLRES_IPV6
use_ipv6 = FALSE;
#endif
arg++;
@ -76,7 +76,7 @@ static int test_resolve(int argc, char *argv[])
puts("Usage: resolve [option] <host>\n"
" --version\n"
" --ipv4"
#if defined(CURLRES_IPV6)
#ifdef CURLRES_IPV6
"\n --ipv6"
#endif
);
@ -88,7 +88,7 @@ static int test_resolve(int argc, char *argv[])
return 2;
#endif
#if defined(CURLRES_IPV6)
#ifdef CURLRES_IPV6
if(use_ipv6) {
/* Check that the system has IPv6 enabled before checking the resolver */
curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);

View file

@ -965,12 +965,12 @@ static bool juggle(curl_socket_t *sockfdp,
FD_ZERO(&fds_write);
FD_ZERO(&fds_err);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET((curl_socket_t)fileno(stdin), &fds_read);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
@ -981,12 +981,12 @@ static bool juggle(curl_socket_t *sockfdp,
/* server mode */
sockfd = listenfd;
/* there's always a socket to wait for */
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
maxfd = (int)sockfd;
@ -1002,12 +1002,12 @@ static bool juggle(curl_socket_t *sockfdp,
}
else {
/* there's always a socket to wait for */
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
maxfd = (int)sockfd;
@ -1019,12 +1019,12 @@ static bool juggle(curl_socket_t *sockfdp,
sockfd = *sockfdp;
/* sockfd turns CURL_SOCKET_BAD when our connection has been closed */
if(CURL_SOCKET_BAD != sockfd) {
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
maxfd = (int)sockfd;

View file

@ -629,35 +629,35 @@ static bool socksd_incoming(curl_socket_t listenfd)
FD_ZERO(&fds_err);
/* there's always a socket to wait for */
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
for(i = 0; i < 2; i++) {
if(c[i].used) {
curl_socket_t fd = c[i].clientfd;
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(fd, &fds_read);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if((int)fd > maxfd)
maxfd = (int)fd;
fd = c[i].remotefd;
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(fd, &fds_read);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if((int)fd > maxfd)

View file

@ -830,12 +830,12 @@ static int sws_get_request(curl_socket_t sock, struct sws_httprequest *req)
FD_ZERO(&input);
FD_ZERO(&output);
got = 0;
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sock, &input);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
do {
@ -1307,12 +1307,12 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port)
timeout.tv_sec = 1; /* 1000 ms */
FD_ZERO(&output);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(serverfd, &output);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
while(1) {
@ -1439,12 +1439,12 @@ static void http_connect(curl_socket_t *infdp,
/* listener socket is monitored to allow client to establish
secondary tunnel only when this tunnel is not established
and primary one is fully operational */
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(rootfd, &input);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
maxfd = rootfd;
@ -1456,12 +1456,12 @@ static void http_connect(curl_socket_t *infdp,
if(clientfd[i] != CURL_SOCKET_BAD) {
if(poll_client_rd[i]) {
/* unless told not to do so, monitor readability */
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(clientfd[i], &input);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(clientfd[i] > maxfd)
@ -1470,12 +1470,12 @@ static void http_connect(curl_socket_t *infdp,
if(poll_client_wr[i] && toc[i]) {
/* unless told not to do so, monitor writability
if there is data ready to be sent to client */
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(clientfd[i], &output);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(clientfd[i] > maxfd)
@ -1486,12 +1486,12 @@ static void http_connect(curl_socket_t *infdp,
if(serverfd[i] != CURL_SOCKET_BAD) {
if(poll_server_rd[i]) {
/* unless told not to do so, monitor readability */
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(serverfd[i], &input);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(serverfd[i] > maxfd)
@ -1500,12 +1500,12 @@ static void http_connect(curl_socket_t *infdp,
if(poll_server_wr[i] && tos[i]) {
/* unless told not to do so, monitor writability
if there is data ready to be sent to server */
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(serverfd[i], &output);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(serverfd[i] > maxfd)
@ -2322,12 +2322,12 @@ static int test_sws(int argc, char *argv[])
for(socket_idx = 0; socket_idx < num_sockets; ++socket_idx) {
/* Listen on all sockets */
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(all_sockets[socket_idx], &input);
#if defined(__DJGPP__)
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(all_sockets[socket_idx] > maxfd)

View file

@ -508,7 +508,7 @@ static int synchnet(curl_socket_t f /* socket to flush */)
curl_socklen_t fromaddrlen;
for(;;) {
#if defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO)
#ifdef HAVE_IOCTLSOCKET_CAMEL_FIONBIO
long i;
(void)IoctlSocket(f, FIONBIO, &i);
#elif defined(HAVE_IOCTLSOCKET)

View file

@ -131,7 +131,7 @@ static CURLcode test_unit1979(char *arg)
buffer);
curlx_dyn_free(&canonical_path);
}
#endif /* !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_AWS) */
#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_AWS */
UNITTEST_END_SIMPLE
}

View file

@ -102,7 +102,7 @@ static CURLcode test_unit1980(char *arg)
buffer);
curlx_dyn_free(&canonical_query);
}
#endif /* !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_AWS) */
#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_AWS */
UNITTEST_END_SIMPLE
}

View file

@ -60,7 +60,7 @@ static CURLcode test_unit3205(char *arg)
"ECDHE-RSA-CHACHA20-POLY1305" },
{ 0xCCA9, "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
"ECDHE-ECDSA-CHACHA20-POLY1305" },
#if defined(USE_MBEDTLS)
#ifdef USE_MBEDTLS
{ 0x002F, "TLS_RSA_WITH_AES_128_CBC_SHA",
"AES128-SHA" },
{ 0x0035, "TLS_RSA_WITH_AES_256_CBC_SHA",
@ -451,19 +451,19 @@ static CURLcode test_unit3205(char *arg)
{ 0xC030, "ECDHE-RSA-AES256-GCM-SHA384"},
{ 0xCCA9, "ECDHE-ECDSA-CHACHA20-POLY1305"},
{ 0xCCA8, "ECDHE-RSA-CHACHA20-POLY1305"},
#if defined(USE_MBEDTLS)
#ifdef USE_MBEDTLS
{ 0x009E, "DHE-RSA-AES128-GCM-SHA256"},
{ 0x009F, "DHE-RSA-AES256-GCM-SHA384"},
#else
{ 0x0000, "DHE-RSA-AES128-GCM-SHA256"},
{ 0x0000, "DHE-RSA-AES256-GCM-SHA384"},
#endif
#if defined(USE_MBEDTLS)
#ifdef USE_MBEDTLS
{ 0xCCAA, "DHE-RSA-CHACHA20-POLY1305"},
#else
{ 0x0000, "DHE-RSA-CHACHA20-POLY1305"},
#endif
#if defined(USE_MBEDTLS)
#ifdef USE_MBEDTLS
{ 0xC023, "ECDHE-ECDSA-AES128-SHA256" },
{ 0xC027, "ECDHE-RSA-AES128-SHA256" },
{ 0xC009, "ECDHE-ECDSA-AES128-SHA" },
@ -482,14 +482,14 @@ static CURLcode test_unit3205(char *arg)
{ 0x0000, "ECDHE-ECDSA-AES256-SHA" },
{ 0x0000, "ECDHE-RSA-AES256-SHA" },
#endif
#if defined(USE_MBEDTLS)
#ifdef USE_MBEDTLS
{ 0x0067, "DHE-RSA-AES128-SHA256" },
{ 0x006B, "DHE-RSA-AES256-SHA256" },
#else
{ 0x0000, "DHE-RSA-AES128-SHA256" },
{ 0x0000, "DHE-RSA-AES256-SHA256" },
#endif
#if defined(USE_MBEDTLS)
#ifdef USE_MBEDTLS
{ 0x009C, "AES128-GCM-SHA256" },
{ 0x009D, "AES256-GCM-SHA384" },
{ 0x003C, "AES128-SHA256" },
@ -605,7 +605,7 @@ static CURLcode test_unit3205(char *arg)
j++;
}
}
#endif /* defined(USE_MBEDTLS) || defined(USE_RUSTLS) */
#endif /* USE_MBEDTLS || USE_RUSTLS */
UNITTEST_END_SIMPLE
}