From bfc7ad3a323b5b6069fe91b2ddd056027eaf37d0 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 26 Feb 2025 00:27:57 +0100 Subject: [PATCH] prefer #ifdef/#ifndef 1 --- include/curl/curl.h | 4 ++-- include/curl/system.h | 2 +- lib/curl_multibyte.h | 2 +- lib/curl_setup.h | 12 ++++++------ lib/curl_setup_once.h | 8 ++++---- lib/system_win32.c | 2 +- lib/system_win32.h | 2 +- lib/timeval.c | 6 +++--- lib/url.c | 18 +++++++++--------- lib/urlapi.c | 2 +- lib/version_win32.c | 4 ++-- lib/version_win32.h | 2 +- lib/warnless.c | 2 +- lib/warnless.h | 4 ++-- src/tool_setup.h | 2 +- src/tool_util.c | 8 ++++---- tests/libtest/lib1531.c | 2 +- tests/libtest/lib670.c | 2 +- tests/libtest/testutil.c | 2 +- tests/server/util.c | 6 +++--- 20 files changed, 46 insertions(+), 46 deletions(-) diff --git a/include/curl/curl.h b/include/curl/curl.h index 346872b39d..9290486e35 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -42,7 +42,7 @@ !defined(CURL_DISABLE_DEPRECATION) && !defined(BUILDING_LIBCURL) #define CURL_DEPRECATED(version, message) \ __attribute__((deprecated("since " # version ". " message))) -#if defined(__IAR_SYSTEMS_ICC__) +#ifdef __IAR_SYSTEMS_ICC__ #define CURL_IGNORE_DEPRECATION(statements) \ _Pragma("diag_suppress=Pe1444") \ statements \ @@ -97,7 +97,7 @@ #include #endif -#if !defined(_WIN32) +#ifndef _WIN32 #include #include #endif diff --git a/include/curl/system.h b/include/curl/system.h index f647f85870..589b21dbc8 100644 --- a/include/curl/system.h +++ b/include/curl/system.h @@ -52,7 +52,7 @@ * */ -#if defined(__DJGPP__) +#ifdef __DJGPP__ # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" diff --git a/lib/curl_multibyte.h b/lib/curl_multibyte.h index dec384e2fe..539b5136bc 100644 --- a/lib/curl_multibyte.h +++ b/lib/curl_multibyte.h @@ -25,7 +25,7 @@ ***************************************************************************/ #include "curl_setup.h" -#if defined(_WIN32) +#ifdef _WIN32 /* * MultiByte conversions using Windows kernel32 library. diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 724aa7f32b..e01c35007e 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -56,7 +56,7 @@ # endif #endif -#if defined(__APPLE__) +#ifdef __APPLE__ #include #include /* Fixup faulty target macro initialization in macOS SDK since v14.4 (as of @@ -276,7 +276,7 @@ * When HTTP is disabled, disable HTTP-only features */ -#if defined(CURL_DISABLE_HTTP) +#ifdef CURL_DISABLE_HTTP # define CURL_DISABLE_ALTSVC 1 # define CURL_DISABLE_COOKIES 1 # define CURL_DISABLE_BASIC_AUTH 1 @@ -771,7 +771,7 @@ #endif /* Single point where USE_NTLM definition might be defined */ -#if !defined(CURL_DISABLE_NTLM) +#ifndef CURL_DISABLE_NTLM # if defined(USE_OPENSSL) || defined(USE_MBEDTLS) || \ defined(USE_GNUTLS) || defined(USE_SECTRANSP) || \ defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \ @@ -811,7 +811,7 @@ /* noreturn attribute */ -#if !defined(CURL_NORETURN) +#ifndef CURL_NORETURN #if (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__clang__) || \ defined(__IAR_SYSTEMS_ICC__) # define CURL_NORETURN __attribute__((__noreturn__)) @@ -824,7 +824,7 @@ /* fallthrough attribute */ -#if !defined(FALLTHROUGH) +#ifndef FALLTHROUGH #if (defined(__GNUC__) && __GNUC__ >= 7) || \ (defined(__clang__) && __clang_major__ >= 10) # define FALLTHROUGH() __attribute__((fallthrough)) @@ -1032,7 +1032,7 @@ int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf, # endif #endif -#if defined(CURL_INLINE) +#ifdef CURL_INLINE /* 'CURL_INLINE' defined, use as-is */ #elif defined(inline) # define CURL_INLINE inline /* 'inline' defined, assumed correct */ diff --git a/lib/curl_setup_once.h b/lib/curl_setup_once.h index 343f35a8b0..0e48e60053 100644 --- a/lib/curl_setup_once.h +++ b/lib/curl_setup_once.h @@ -125,7 +125,7 @@ struct timeval { #endif -#if defined(__minix) +#ifdef __minix /* Minix does not support recv on TCP sockets */ #define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \ (RECV_TYPE_ARG2)(y), \ @@ -165,7 +165,7 @@ struct timeval { #endif /* HAVE_RECV */ -#if defined(__minix) +#ifdef __minix /* Minix does not support send on TCP sockets */ #define swrite(x,y,z) (ssize_t)write((SEND_TYPE_ARG1)(x), \ (SEND_TYPE_ARG2)(y), \ @@ -187,7 +187,7 @@ struct timeval { * Function-like macro definition used to close a socket. */ -#if defined(HAVE_CLOSESOCKET) +#ifdef HAVE_CLOSESOCKET # define sclose(x) closesocket((x)) #elif defined(HAVE_CLOSESOCKET_CAMEL) # define sclose(x) CloseSocket((x)) @@ -202,7 +202,7 @@ struct timeval { /* * Stack-independent version of fcntl() on sockets: */ -#if defined(USE_LWIPSOCK) +#ifdef USE_LWIPSOCK # define sfcntl lwip_fcntl #else # define sfcntl fcntl diff --git a/lib/system_win32.c b/lib/system_win32.c index bfe1606776..7a9551d3f6 100644 --- a/lib/system_win32.c +++ b/lib/system_win32.c @@ -24,7 +24,7 @@ #include "curl_setup.h" -#if defined(_WIN32) +#ifdef _WIN32 #include #include "system_win32.h" diff --git a/lib/system_win32.h b/lib/system_win32.h index 024d959f32..b8333c647e 100644 --- a/lib/system_win32.h +++ b/lib/system_win32.h @@ -26,7 +26,7 @@ #include "curl_setup.h" -#if defined(_WIN32) +#ifdef _WIN32 #include diff --git a/lib/timeval.c b/lib/timeval.c index bb29bfdfee..890992efce 100644 --- a/lib/timeval.c +++ b/lib/timeval.c @@ -24,7 +24,7 @@ #include "timeval.h" -#if defined(_WIN32) +#ifdef _WIN32 #include #include "system_win32.h" @@ -42,12 +42,12 @@ struct curltime Curl_now(void) } else { /* Disable /analyze warning that GetTickCount64 is preferred */ -#if defined(_MSC_VER) +#ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:28159) #endif DWORD milliseconds = GetTickCount(); -#if defined(_MSC_VER) +#ifdef _MSC_VER #pragma warning(pop) #endif diff --git a/lib/url.c b/lib/url.c index a12944cad5..b219e51c53 100644 --- a/lib/url.c +++ b/lib/url.c @@ -427,7 +427,7 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data) */ if(Curl_ssl_backend() != CURLSSLBACKEND_SCHANNEL && Curl_ssl_backend() != CURLSSLBACKEND_SECURETRANSPORT) { -#if defined(CURL_CA_BUNDLE) +#ifdef CURL_CA_BUNDLE result = Curl_setstropt(&set->str[STRING_SSL_CAFILE], CURL_CA_BUNDLE); if(result) return result; @@ -438,7 +438,7 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data) return result; #endif #endif -#if defined(CURL_CA_PATH) +#ifdef CURL_CA_PATH result = Curl_setstropt(&set->str[STRING_SSL_CAPATH], CURL_CA_PATH); if(result) return result; @@ -1127,7 +1127,7 @@ static bool url_match_conn(struct connectdata *conn, void *userdata) } } -#if defined(USE_NTLM) +#ifdef USE_NTLM /* If we are looking for an HTTP+NTLM connection, check if this is already authenticating with the right credentials. If not, keep looking so that we can reuse NTLM connections if @@ -1307,7 +1307,7 @@ void Curl_verboseconnect(struct Curl_easy *data, infof(data, "Connected to %s (%s) port %u", CURL_CONN_HOST_DISPNAME(conn), conn->primary.remote_ip, conn->primary.remote_port); -#if !defined(CURL_DISABLE_HTTP) +#ifndef CURL_DISABLE_HTTP if(conn->handler->protocol & PROTO_FAMILY_HTTP) { switch(conn->alpn) { case CURL_HTTP_VERSION_3: @@ -1462,7 +1462,7 @@ const struct Curl_handler *Curl_getn_scheme_handler(const char *scheme, #else NULL, #endif -#if defined(USE_SSH) +#ifdef USE_SSH &Curl_handler_sftp, #else NULL, @@ -1709,7 +1709,7 @@ static void zonefrom_url(CURLU *uh, struct Curl_easy *data, if(!Curl_str_number(&p, &scope, UINT_MAX)) /* A plain number, use it directly as a scope id. */ conn->scope_id = (unsigned int)scope; -#if defined(HAVE_IF_NAMETOINDEX) +#ifdef HAVE_IF_NAMETOINDEX else { #elif defined(_WIN32) else if(Curl_if_nametoindex) { @@ -1718,7 +1718,7 @@ static void zonefrom_url(CURLU *uh, struct Curl_easy *data, #if defined(HAVE_IF_NAMETOINDEX) || defined(_WIN32) /* Zone identifier is not numeric */ unsigned int scopeidx = 0; -#if defined(_WIN32) +#ifdef _WIN32 scopeidx = Curl_if_nametoindex(zoneid); #else scopeidx = if_nametoindex(zoneid); @@ -2868,7 +2868,7 @@ static CURLcode parse_connect_to_host_port(struct Curl_easy *data, int port = -1; CURLcode result = CURLE_OK; -#if defined(CURL_DISABLE_VERBOSE_STRINGS) +#ifdef CURL_DISABLE_VERBOSE_STRINGS (void) data; #endif @@ -3689,7 +3689,7 @@ static CURLcode create_conn(struct Curl_easy *data, goto out; } -#if defined(USE_NTLM) +#ifdef USE_NTLM /* If NTLM is requested in a part of this connection, make sure we do not assume the state is fine as this is a fresh connection and NTLM is connection based. */ diff --git a/lib/urlapi.c b/lib/urlapi.c index 04446dfd52..8754273738 100644 --- a/lib/urlapi.c +++ b/lib/urlapi.c @@ -998,7 +998,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) ptr += 9; /* now points to the slash after the host */ } else { -#if defined(_WIN32) +#ifdef _WIN32 size_t len; /* the hostname, NetBIOS computer name, can not contain disallowed diff --git a/lib/version_win32.c b/lib/version_win32.c index d58dbec724..ae3c74672a 100644 --- a/lib/version_win32.c +++ b/lib/version_win32.c @@ -24,7 +24,7 @@ #include "curl_setup.h" -#if defined(_WIN32) +#ifdef _WIN32 #include #include "version_win32.h" @@ -79,7 +79,7 @@ bool curlx_verify_windows_version(const unsigned int majorVersion, { bool matched = FALSE; -#if defined(CURL_WINDOWS_UWP) +#ifdef CURL_WINDOWS_UWP /* We have no way to determine the Windows version from Windows apps, so let's assume we are running on the target Windows version. */ const WORD fullVersion = MAKEWORD(minorVersion, majorVersion); diff --git a/lib/version_win32.h b/lib/version_win32.h index 95a9e7f215..a91631eb23 100644 --- a/lib/version_win32.h +++ b/lib/version_win32.h @@ -26,7 +26,7 @@ #include "curl_setup.h" -#if defined(_WIN32) +#ifdef _WIN32 /* Version condition */ typedef enum { diff --git a/lib/warnless.c b/lib/warnless.c index 0d608e46d6..218e518fd7 100644 --- a/lib/warnless.c +++ b/lib/warnless.c @@ -298,7 +298,7 @@ size_t curlx_sitouz(int sinum) #endif } -#if defined(_WIN32) +#ifdef _WIN32 ssize_t curlx_read(int fd, void *buf, size_t count) { diff --git a/lib/warnless.h b/lib/warnless.h index 63b473c571..11c5e8b0b8 100644 --- a/lib/warnless.h +++ b/lib/warnless.h @@ -57,7 +57,7 @@ unsigned short curlx_uitous(unsigned int uinum); size_t curlx_sitouz(int sinum); -#if defined(_WIN32) +#ifdef _WIN32 ssize_t curlx_read(int fd, void *buf, size_t count); @@ -70,7 +70,7 @@ ssize_t curlx_write(int fd, const void *buf, size_t count); #ifndef HEADER_CURL_WARNLESS_H_REDEFS #define HEADER_CURL_WARNLESS_H_REDEFS -#if defined(_WIN32) +#ifdef _WIN32 #undef read #define read(fd, buf, count) curlx_read(fd, buf, count) #undef write diff --git a/src/tool_setup.h b/src/tool_setup.h index cafe373ea8..57cd9a57fc 100644 --- a/src/tool_setup.h +++ b/src/tool_setup.h @@ -66,7 +66,7 @@ extern FILE *tool_stderr; # include "tool_strdup.h" #endif -#if defined(_WIN32) +#ifdef _WIN32 # define CURL_STRICMP(p1, p2) _stricmp(p1, p2) #elif defined(HAVE_STRCASECMP) # ifdef HAVE_STRINGS_H diff --git a/src/tool_util.c b/src/tool_util.c index c1891283b5..446bb7199c 100644 --- a/src/tool_util.c +++ b/src/tool_util.c @@ -28,7 +28,7 @@ #include "curlx.h" #include "memdebug.h" /* keep this as LAST include */ -#if defined(_WIN32) +#ifdef _WIN32 /* In case of bug fix this function has a counterpart in timeval.c */ struct timeval tvnow(void) @@ -43,12 +43,12 @@ struct timeval tvnow(void) } else { /* Disable /analyze warning that GetTickCount64 is preferred */ -#if defined(_MSC_VER) +#ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:28159) #endif DWORD milliseconds = GetTickCount(); -#if defined(_MSC_VER) +#ifdef _MSC_VER #pragma warning(pop) #endif @@ -121,7 +121,7 @@ struct timeval tvnow(void) #endif -#if defined(_WIN32) +#ifdef _WIN32 struct timeval tvrealnow(void) { diff --git a/tests/libtest/lib1531.c b/tests/libtest/lib1531.c index 2021e08790..ea250b607e 100644 --- a/tests/libtest/lib1531.c +++ b/tests/libtest/lib1531.c @@ -109,7 +109,7 @@ CURLcode test(char *URL) curl_multi_fdset() doc. */ if(maxfd == -1) { -#if defined(_WIN32) +#ifdef _WIN32 Sleep(100); rc = 0; #else diff --git a/tests/libtest/lib670.c b/tests/libtest/lib670.c index e03e8abebf..2a9c21f298 100644 --- a/tests/libtest/lib670.c +++ b/tests/libtest/lib670.c @@ -213,7 +213,7 @@ CURLcode test(char *URL) mres = curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcept, &maxfd); if(mres) break; -#if defined(_WIN32) +#ifdef _WIN32 if(maxfd == -1) Sleep(100); else diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index 51593501ff..d058e9e4df 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -26,7 +26,7 @@ #include "testutil.h" #include "memdebug.h" -#if defined(_WIN32) +#ifdef _WIN32 struct timeval tutil_tvnow(void) { diff --git a/tests/server/util.c b/tests/server/util.c index 42a4f857e8..0e511d9677 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -243,7 +243,7 @@ int wait_ms(int timeout_ms) CURL_SETERRNO(EINVAL); return -1; } -#if defined(MSDOS) +#ifdef MSDOS delay(timeout_ms); #elif defined(USE_WINSOCK) Sleep((DWORD)timeout_ms); @@ -279,7 +279,7 @@ curl_off_t our_getpid(void) curl_off_t pid; pid = (curl_off_t)Curl_getpid(); -#if defined(_WIN32) +#ifdef _WIN32 /* store pid + MAX_PID to avoid conflict with Cygwin/msys PIDs, see also: * - 2019-01-31: https://cygwin.com/git/?p=newlib-cygwin.git;a=commit; ↵ * h=b5e1003722cb14235c4f166be72c09acdffc62ea @@ -365,7 +365,7 @@ void clear_advisor_read_lock(const char *filename) } -#if defined(_WIN32) +#ifdef _WIN32 static struct timeval tvnow(void) {