diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 221a0ab311..9ad981cab3 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -773,7 +773,7 @@ jobs: curl --disable --fail --silent --show-error --connect-timeout 15 --max-time 120 --retry 6 --retry-connrefused \ --compressed https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | \ sudo tee /etc/apt/trusted.gpg.d/intel-sw.asc >/dev/null - sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" + sudo add-apt-repository 'deb https://apt.repos.intel.com/oneapi all main' sudo apt-get -o Dpkg::Use-Pty=0 install intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic source /opt/intel/oneapi/setvars.sh printenv >> "$GITHUB_ENV" diff --git a/.github/workflows/non-native.yml b/.github/workflows/non-native.yml index 0dbc92d03d..0840e235db 100644 --- a/.github/workflows/non-native.yml +++ b/.github/workflows/non-native.yml @@ -381,24 +381,24 @@ jobs: -DCMAKE_SYSTEM_NAME=DOS \ -DCMAKE_SYSTEM_PROCESSOR=x86 \ -DCMAKE_C_COMPILER_TARGET=i586-pc-msdosdjgpp \ - -DCMAKE_C_COMPILER="$HOME/djgpp/bin/i586-pc-msdosdjgpp-gcc" \ + -DCMAKE_C_COMPILER="$HOME"/djgpp/bin/i586-pc-msdosdjgpp-gcc \ -DCMAKE_UNITY_BUILD=ON \ -DCURL_WERROR=ON \ -DCURL_ENABLE_SSL=OFF -DCURL_USE_LIBPSL=OFF \ - -DZLIB_INCLUDE_DIR="$HOME/djgpp/include" \ - -DZLIB_LIBRARY="$HOME/djgpp/lib/libz.a" \ - -DWATT_ROOT="$HOME/djgpp/net/watt" + -DZLIB_INCLUDE_DIR="$HOME"/djgpp/include \ + -DZLIB_LIBRARY="$HOME"/djgpp/lib/libz.a \ + -DWATT_ROOT="$HOME"/djgpp/net/watt else autoreconf -fi mkdir bld && cd bld && ../configure --enable-unity --enable-warnings --enable-werror --disable-shared \ --disable-dependency-tracking --enable-option-checking=fatal \ - CC="$HOME/djgpp/bin/i586-pc-msdosdjgpp-gcc" \ - AR="$HOME/djgpp/bin/i586-pc-msdosdjgpp-ar" \ - RANLIB="$HOME/djgpp/bin/i586-pc-msdosdjgpp-ranlib" \ - WATT_ROOT="$HOME/djgpp/net/watt" \ + CC="$HOME"/djgpp/bin/i586-pc-msdosdjgpp-gcc \ + AR="$HOME"/djgpp/bin/i586-pc-msdosdjgpp-ar \ + RANLIB="$HOME"/djgpp/bin/i586-pc-msdosdjgpp-ranlib \ + WATT_ROOT="$HOME"/djgpp/net/watt \ --host=i586-pc-msdosdjgpp \ --without-ssl --without-libpsl \ - --with-zlib="$HOME/djgpp" + --with-zlib="$HOME"/djgpp fi - name: 'configure log' diff --git a/configure.ac b/configure.ac index 4e08eafa42..ef143acf13 100644 --- a/configure.ac +++ b/configure.ac @@ -1784,7 +1784,7 @@ int main(int argc, char **argv) #else (void)argc; argv[0][0] = ' '; - return (argv[0][0] == ' ')?0:1; + return (argv[0][0] == ' ') ? 0 : 1; #endif } ]],[ diff --git a/docs/examples/crawler.c b/docs/examples/crawler.c index 915a7cae47..c214df64b2 100644 --- a/docs/examples/crawler.c +++ b/docs/examples/crawler.c @@ -131,18 +131,18 @@ static size_t follow_links(CURLM *multi, struct memory *mem, const char *url) xmlChar *xpath; xmlNodeSetPtr nodeset; xmlXPathContextPtr context; - xmlXPathObjectPtr result; + xmlXPathObjectPtr object; if(!doc) return 0; xpath = (xmlChar *)"//a/@href"; context = xmlXPathNewContext(doc); - result = xmlXPathEvalExpression(xpath, context); + object = xmlXPathEvalExpression(xpath, context); xmlXPathFreeContext(context); - if(!result) + if(!object) return 0; - nodeset = result->nodesetval; + nodeset = object->nodesetval; if(xmlXPathNodeSetIsEmpty(nodeset)) { - xmlXPathFreeObject(result); + xmlXPathFreeObject(object); return 0; } count = 0; @@ -167,7 +167,7 @@ static size_t follow_links(CURLM *multi, struct memory *mem, const char *url) } xmlFree(link); } - xmlXPathFreeObject(result); + xmlXPathFreeObject(object); return count; } diff --git a/docs/examples/sessioninfo.c b/docs/examples/sessioninfo.c index 3872180b77..0b8b9f0ae2 100644 --- a/docs/examples/sessioninfo.c +++ b/docs/examples/sessioninfo.c @@ -38,6 +38,7 @@ #include #include + #include #include diff --git a/docs/examples/smooth-gtk-thread.c b/docs/examples/smooth-gtk-thread.c index 694426f911..3c2f259048 100644 --- a/docs/examples/smooth-gtk-thread.c +++ b/docs/examples/smooth-gtk-thread.c @@ -34,7 +34,6 @@ * gcc -ggdb `pkg-config --cflags --libs gtk+-2.0` -lcurl -lssl -lcrypto * -lgthread-2.0 -dl smooth-gtk-thread.c -o smooth-gtk-thread */ - #include #include #include diff --git a/docs/examples/unixsocket.c b/docs/examples/unixsocket.c index 01810fd624..4a8c34218e 100644 --- a/docs/examples/unixsocket.c +++ b/docs/examples/unixsocket.c @@ -26,6 +26,7 @@ * */ #include + #include #ifdef USE_ABSTRACT diff --git a/docs/examples/usercertinmem.c b/docs/examples/usercertinmem.c index 7caa4be626..0946360ef8 100644 --- a/docs/examples/usercertinmem.c +++ b/docs/examples/usercertinmem.c @@ -39,10 +39,10 @@ #include -#include - #include +#include + #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic ignored "-Woverlength-strings" #endif diff --git a/docs/examples/websocket-updown.c b/docs/examples/websocket-updown.c index 3a7f07767f..3000be0594 100644 --- a/docs/examples/websocket-updown.c +++ b/docs/examples/websocket-updown.c @@ -27,6 +27,7 @@ */ #include #include + #include static size_t write_cb(char *b, size_t size, size_t nitems, void *p) diff --git a/docs/libcurl/opts/CURLINFO_CONDITION_UNMET.md b/docs/libcurl/opts/CURLINFO_CONDITION_UNMET.md index 8e44e7bd94..133070f5ad 100644 --- a/docs/libcurl/opts/CURLINFO_CONDITION_UNMET.md +++ b/docs/libcurl/opts/CURLINFO_CONDITION_UNMET.md @@ -64,7 +64,7 @@ int main(void) long unmet; result = curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet); if(result == CURLE_OK) { - printf("The time condition was %sfulfilled\n", unmet?"NOT":""); + printf("The time condition was %sfulfilled\n", unmet ? "NOT" : ""); } } } diff --git a/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.md b/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.md index 4ff3578735..2a65509ede 100644 --- a/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.md +++ b/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.md @@ -55,10 +55,10 @@ int main(void) printf("No auth available, perhaps no 401?\n"); else { printf("%s%s%s%s\n", - auth & CURLAUTH_BASIC ? "Basic ":"", - auth & CURLAUTH_DIGEST ? "Digest ":"", - auth & CURLAUTH_NEGOTIATE ? "Negotiate ":"", - auth % CURLAUTH_NTLM ? "NTLM ":""); + auth & CURLAUTH_BASIC ? "Basic " : "", + auth & CURLAUTH_DIGEST ? "Digest " : "", + auth & CURLAUTH_NEGOTIATE ? "Negotiate " : "", + auth % CURLAUTH_NTLM ? "NTLM " : ""); } } } diff --git a/docs/libcurl/opts/CURLINFO_PROXYAUTH_AVAIL.md b/docs/libcurl/opts/CURLINFO_PROXYAUTH_AVAIL.md index e38f2f6245..c5110ef377 100644 --- a/docs/libcurl/opts/CURLINFO_PROXYAUTH_AVAIL.md +++ b/docs/libcurl/opts/CURLINFO_PROXYAUTH_AVAIL.md @@ -56,10 +56,10 @@ int main(void) printf("No proxy auth available, perhaps no 407?\n"); else { printf("%s%s%s%s\n", - auth & CURLAUTH_BASIC ? "Basic ":"", - auth & CURLAUTH_DIGEST ? "Digest ":"", - auth & CURLAUTH_NEGOTIATE ? "Negotiate ":"", - auth % CURLAUTH_NTLM ? "NTLM ":""); + auth & CURLAUTH_BASIC ? "Basic " : "", + auth & CURLAUTH_DIGEST ? "Digest " : "", + auth & CURLAUTH_NEGOTIATE ? "Negotiate " : "", + auth % CURLAUTH_NTLM ? "NTLM " : ""); } } } diff --git a/docs/libcurl/opts/CURLINFO_TLS_SESSION.md b/docs/libcurl/opts/CURLINFO_TLS_SESSION.md index 39f1a43e2f..cbbd5c0298 100644 --- a/docs/libcurl/opts/CURLINFO_TLS_SESSION.md +++ b/docs/libcurl/opts/CURLINFO_TLS_SESSION.md @@ -37,7 +37,7 @@ This option is exactly the same as CURLINFO_TLS_SSL_PTR(3) except in the case of OpenSSL and wolfSSL. If the session *backend* is CURLSSLBACKEND_OPENSSL the session *internals* pointer varies depending on the option: -## OpenSSL: +## OpenSSL CURLINFO_TLS_SESSION(3) OpenSSL session *internals* is **SSL_CTX ***. diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index 80126ce056..8b72214cad 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -912,7 +912,7 @@ CURLcode Curl_async_ares_set_dns_local_ip4(struct Curl_easy *data) struct in_addr a4; const char *local_ip4 = data->set.str[STRING_DNS_LOCAL_IP4]; - if((!local_ip4) || (local_ip4[0] == 0)) { + if(!local_ip4 || (local_ip4[0] == 0)) { a4.s_addr = 0; /* disabled: do not bind to a specific address */ } else { @@ -941,7 +941,7 @@ CURLcode Curl_async_ares_set_dns_local_ip6(struct Curl_easy *data) unsigned char a6[INET6_ADDRSTRLEN]; const char *local_ip6 = data->set.str[STRING_DNS_LOCAL_IP6]; - if((!local_ip6) || (local_ip6[0] == 0)) { + if(!local_ip6 || (local_ip6[0] == 0)) { /* disabled: do not bind to a specific address */ memset(a6, 0, sizeof(a6)); } diff --git a/lib/bufq.h b/lib/bufq.h index bcd7df2ab9..e3fbc390d2 100644 --- a/lib/bufq.h +++ b/lib/bufq.h @@ -104,7 +104,7 @@ struct bufq { * Default behaviour: chunk limit is "hard", meaning attempts to write * more bytes than can be hold in `max_chunks` is refused and will return * -1, CURLE_AGAIN. */ -#define BUFQ_OPT_NONE (0) +#define BUFQ_OPT_NONE 0 /** * Make `max_chunks` a "soft" limit. A bufq will report that it is "full" * when `max_chunks` are used, but allows writing beyond this limit. diff --git a/lib/config-mac.h b/lib/config-mac.h index 8f32a51a3f..e9806b4e37 100644 --- a/lib/config-mac.h +++ b/lib/config-mac.h @@ -59,7 +59,7 @@ #define HAVE_SIGACTION 1 -#define CURL_DISABLE_LDAP 1 +#define CURL_DISABLE_LDAP #define HAVE_IOCTL_FIONBIO 1 diff --git a/lib/curl_addrinfo.c b/lib/curl_addrinfo.c index f1eaa6bcb6..1b8dd7a225 100644 --- a/lib/curl_addrinfo.c +++ b/lib/curl_addrinfo.c @@ -62,9 +62,9 @@ #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 910) && \ defined(__OPTIMIZE__) && defined(__unix__) && defined(__i386__) /* workaround icc 9.1 optimizer issue */ -# define vqualifier volatile +# define vqualifier volatile #else -# define vqualifier +# define vqualifier #endif void Curl_freeaddrinfo(struct Curl_addrinfo *cahead) diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c index 2edc7b07ce..6e772a43ba 100644 --- a/lib/curl_ntlm_core.c +++ b/lib/curl_ntlm_core.c @@ -138,7 +138,7 @@ * * bytes [in/out] - The data whose parity bits are to be adjusted for * odd parity. - * len [out] - The length of the data. + * len [in] - The length of the data. */ static void curl_des_set_odd_parity(unsigned char *bytes, size_t len) { diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 559f586b78..906491fed5 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -286,16 +286,36 @@ * When HTTP is disabled, disable HTTP-only features */ #ifdef CURL_DISABLE_HTTP -# define CURL_DISABLE_ALTSVC 1 -# define CURL_DISABLE_COOKIES 1 -# define CURL_DISABLE_BASIC_AUTH 1 -# define CURL_DISABLE_BEARER_AUTH 1 -# define CURL_DISABLE_AWS 1 -# define CURL_DISABLE_DOH 1 -# define CURL_DISABLE_FORM_API 1 -# define CURL_DISABLE_HEADERS_API 1 -# define CURL_DISABLE_HSTS 1 -# define CURL_DISABLE_HTTP_AUTH 1 +# ifndef CURL_DISABLE_ALTSVC +# define CURL_DISABLE_ALTSVC +# endif +# ifndef CURL_DISABLE_COOKIES +# define CURL_DISABLE_COOKIES +# endif +# ifndef CURL_DISABLE_BASIC_AUTH +# define CURL_DISABLE_BASIC_AUTH +# endif +# ifndef CURL_DISABLE_BEARER_AUTH +# define CURL_DISABLE_BEARER_AUTH +# endif +# ifndef CURL_DISABLE_AWS +# define CURL_DISABLE_AWS +# endif +# ifndef CURL_DISABLE_DOH +# define CURL_DISABLE_DOH +# endif +# ifndef CURL_DISABLE_FORM_API +# define CURL_DISABLE_FORM_API +# endif +# ifndef CURL_DISABLE_HEADERS_API +# define CURL_DISABLE_HEADERS_API +# endif +# ifndef CURL_DISABLE_HSTS +# define CURL_DISABLE_HSTS +# endif +# ifndef CURL_DISABLE_HTTP_AUTH +# define CURL_DISABLE_HTTP_AUTH +# endif # ifndef CURL_DISABLE_WEBSOCKETS # define CURL_DISABLE_WEBSOCKETS /* no WebSockets without HTTP present */ # endif @@ -793,7 +813,7 @@ (defined(__clang__) && __clang_major__ >= 10) # define FALLTHROUGH() __attribute__((fallthrough)) #else -# define FALLTHROUGH() do {} while (0) +# define FALLTHROUGH() do {} while(0) #endif #endif @@ -1131,9 +1151,9 @@ typedef unsigned int curl_bit; #include "curlx/warnless.h" #ifdef _WIN32 -# undef read +# undef read # define read(fd, buf, count) (ssize_t)_read(fd, buf, curlx_uztoui(count)) -# undef write +# undef write # define write(fd, buf, count) (ssize_t)_write(fd, buf, curlx_uztoui(count)) /* Avoid VS2005+ _CRT_NONSTDC_NO_DEPRECATE warnings about non-portable funcs */ # undef fileno diff --git a/lib/curl_trc.c b/lib/curl_trc.c index bbec332f99..b29a9b09d7 100644 --- a/lib/curl_trc.c +++ b/lib/curl_trc.c @@ -487,7 +487,7 @@ void Curl_trc_ws(struct Curl_easy *data, const char *fmt, ...) } #endif /* !CURL_DISABLE_WEBSOCKETS && !CURL_DISABLE_HTTP */ -#define TRC_CT_NONE (0) +#define TRC_CT_NONE 0 #define TRC_CT_PROTOCOL (1 << 0) #define TRC_CT_NETWORK (1 << 1) #define TRC_CT_PROXY (1 << 2) diff --git a/lib/curl_trc.h b/lib/curl_trc.h index 58903844ac..1520ef3020 100644 --- a/lib/curl_trc.h +++ b/lib/curl_trc.h @@ -206,7 +206,7 @@ void Curl_trc_ws(struct Curl_easy *data, #define infof(data, ...) \ do { \ - (void)data; \ + (void)(data); \ } while(0) #define CURL_TRC_M(data, ...) \ do { \ @@ -322,9 +322,9 @@ extern struct curl_trc_feat Curl_trc_feat_timer; #else /* CURL_DISABLE_VERBOSE_STRINGS */ /* All informational messages are not compiled in for size savings */ -#define Curl_trc_is_verbose(d) (FALSE) -#define Curl_trc_cf_is_verbose(x, y) (FALSE) -#define Curl_trc_ft_is_verbose(x, y) (FALSE) +#define Curl_trc_is_verbose(d) FALSE +#define Curl_trc_cf_is_verbose(x, y) FALSE +#define Curl_trc_ft_is_verbose(x, y) FALSE #define CURL_MSTATE_NAME(x) ((void)(x), "-") #define CURL_TRC_EASY_TIMERS(x) Curl_nop_stmt #endif /* !CURL_DISABLE_VERBOSE_STRINGS */ diff --git a/lib/curlx/fopen.h b/lib/curlx/fopen.h index d23dc82445..c4af828d81 100644 --- a/lib/curlx/fopen.h +++ b/lib/curlx/fopen.h @@ -34,7 +34,7 @@ int curlx_fseek(void *stream, curl_off_t offset, int whence); #ifdef _WIN32 -#include /* for _fstati64, struct _stati64 */ +#include /* for _fstati64(), struct _stati64 */ #ifndef CURL_WINDOWS_UWP HANDLE curlx_CreateFile(const char *filename, DWORD dwDesiredAccess, diff --git a/lib/curlx/inet_ntop.h b/lib/curlx/inet_ntop.h index 45b63d97a5..d57b217c96 100644 --- a/lib/curlx/inet_ntop.h +++ b/lib/curlx/inet_ntop.h @@ -37,7 +37,7 @@ #endif #ifdef __AMIGA__ #define curlx_inet_ntop(af, addr, buf, size) \ - (char *)inet_ntop(af, CURL_UNCONST(addr), (unsigned char *)buf, \ + (char *)inet_ntop(af, CURL_UNCONST(addr), (unsigned char *)(buf), \ (curl_socklen_t)(size)) #else #define curlx_inet_ntop(af, addr, buf, size) \ diff --git a/lib/curlx/timeval.c b/lib/curlx/timeval.c index 734b784c04..d01884f7fe 100644 --- a/lib/curlx/timeval.c +++ b/lib/curlx/timeval.c @@ -53,19 +53,19 @@ void curlx_pnow(struct curltime *pnow) void curlx_pnow(struct curltime *pnow) { /* - ** clock_gettime() is granted to be increased monotonically when the - ** monotonic clock is queried. Time starting point is unspecified, it - ** could be the system start-up time, the Epoch, or something else, - ** in any case the time starting point does not change once that the - ** system has started up. - */ + * clock_gettime() is granted to be increased monotonically when the + * monotonic clock is queried. Time starting point is unspecified, it + * could be the system start-up time, the Epoch, or something else, + * in any case the time starting point does not change once that the + * system has started up. + */ struct timespec tsnow; /* - ** clock_gettime() may be defined by Apple's SDK as weak symbol thus - ** code compiles but fails during runtime if clock_gettime() is - ** called on unsupported OS version. - */ + * clock_gettime() may be defined by Apple's SDK as weak symbol thus + * code compiles but fails during runtime if clock_gettime() is + * called on unsupported OS version. + */ #if defined(__APPLE__) && defined(HAVE_BUILTIN_AVAILABLE) && \ (HAVE_BUILTIN_AVAILABLE == 1) bool have_clock_gettime = FALSE; @@ -96,10 +96,10 @@ void curlx_pnow(struct curltime *pnow) pnow->tv_usec = (int)(tsnow.tv_nsec / 1000); } /* - ** Even when the configure process has truly detected monotonic clock - ** availability, it might happen that it is not actually available at - ** runtime. When this occurs simply fallback to other time source. - */ + * Even when the configure process has truly detected monotonic clock + * availability, it might happen that it is not actually available at + * runtime. When this occurs simply fallback to other time source. + */ #ifdef HAVE_GETTIMEOFDAY else { struct timeval now; @@ -122,11 +122,11 @@ void curlx_pnow(struct curltime *pnow) void curlx_pnow(struct curltime *pnow) { /* - ** Monotonic timer on macOS is provided by mach_absolute_time(), which - ** returns time in Mach "absolute time units," which are platform-dependent. - ** To convert to nanoseconds, one must use conversion factors specified by - ** mach_timebase_info(). - */ + * Monotonic timer on macOS is provided by mach_absolute_time(), which + * returns time in Mach "absolute time units," which are platform-dependent. + * To convert to nanoseconds, one must use conversion factors specified by + * mach_timebase_info(). + */ static mach_timebase_info_data_t timebase; uint64_t usecs; @@ -147,10 +147,10 @@ void curlx_pnow(struct curltime *pnow) void curlx_pnow(struct curltime *pnow) { /* - ** gettimeofday() is not granted to be increased monotonically, due to - ** clock drifting and external source time synchronization it can jump - ** forward or backward in time. - */ + * gettimeofday() is not granted to be increased monotonically, due to + * clock drifting and external source time synchronization it can jump + * forward or backward in time. + */ struct timeval now; (void)gettimeofday(&now, NULL); pnow->tv_sec = now.tv_sec; @@ -162,8 +162,8 @@ void curlx_pnow(struct curltime *pnow) void curlx_pnow(struct curltime *pnow) { /* - ** time() returns the value of time in seconds since the Epoch. - */ + * time() returns the value of time in seconds since the Epoch. + */ pnow->tv_sec = time(NULL); pnow->tv_usec = 0; } diff --git a/lib/curlx/warnless.c b/lib/curlx/warnless.c index 8c1be2d589..91b194042f 100644 --- a/lib/curlx/warnless.c +++ b/lib/curlx/warnless.c @@ -49,9 +49,8 @@ #define CURL_MASK_SSIZE_T (CURL_MASK_USIZE_T >> 1) /* -** unsigned long to unsigned char -*/ - + * unsigned long to unsigned char + */ unsigned char curlx_ultouc(unsigned long ulnum) { #ifdef __INTEL_COMPILER @@ -68,9 +67,8 @@ unsigned char curlx_ultouc(unsigned long ulnum) } /* -** unsigned size_t to signed int -*/ - + * unsigned size_t to signed int + */ int curlx_uztosi(size_t uznum) { #ifdef __INTEL_COMPILER @@ -87,9 +85,8 @@ int curlx_uztosi(size_t uznum) } /* -** unsigned size_t to unsigned long -*/ - + * unsigned size_t to unsigned long + */ unsigned long curlx_uztoul(size_t uznum) { #ifdef __INTEL_COMPILER @@ -108,9 +105,8 @@ unsigned long curlx_uztoul(size_t uznum) } /* -** unsigned size_t to unsigned int -*/ - + * unsigned size_t to unsigned int + */ unsigned int curlx_uztoui(size_t uznum) { #ifdef __INTEL_COMPILER @@ -129,9 +125,8 @@ unsigned int curlx_uztoui(size_t uznum) } /* -** signed long to signed int -*/ - + * signed long to signed int + */ int curlx_sltosi(long slnum) { #ifdef __INTEL_COMPILER @@ -151,9 +146,8 @@ int curlx_sltosi(long slnum) } /* -** signed long to unsigned int -*/ - + * signed long to unsigned int + */ unsigned int curlx_sltoui(long slnum) { #ifdef __INTEL_COMPILER @@ -173,9 +167,8 @@ unsigned int curlx_sltoui(long slnum) } /* -** signed long to unsigned short -*/ - + * signed long to unsigned short + */ unsigned short curlx_sltous(long slnum) { #ifdef __INTEL_COMPILER @@ -193,9 +186,8 @@ unsigned short curlx_sltous(long slnum) } /* -** unsigned size_t to signed ssize_t -*/ - + * unsigned size_t to signed ssize_t + */ ssize_t curlx_uztosz(size_t uznum) { #ifdef __INTEL_COMPILER @@ -212,9 +204,8 @@ ssize_t curlx_uztosz(size_t uznum) } /* -** signed curl_off_t to unsigned size_t -*/ - + * signed curl_off_t to unsigned size_t + */ size_t curlx_sotouz(curl_off_t sonum) { #ifdef __INTEL_COMPILER @@ -231,9 +222,8 @@ size_t curlx_sotouz(curl_off_t sonum) } /* -** signed ssize_t to signed int -*/ - + * signed ssize_t to signed int + */ int curlx_sztosi(ssize_t sznum) { #ifdef __INTEL_COMPILER @@ -253,9 +243,8 @@ int curlx_sztosi(ssize_t sznum) } /* -** unsigned int to unsigned short -*/ - + * unsigned int to unsigned short + */ unsigned short curlx_uitous(unsigned int uinum) { #ifdef __INTEL_COMPILER @@ -272,9 +261,8 @@ unsigned short curlx_uitous(unsigned int uinum) } /* -** signed int to unsigned size_t -*/ - + * signed int to unsigned size_t + */ size_t curlx_sitouz(int sinum) { #ifdef __INTEL_COMPILER diff --git a/lib/cw-pause.c b/lib/cw-pause.c index 2489a330a0..ec611879d1 100644 --- a/lib/cw-pause.c +++ b/lib/cw-pause.c @@ -34,7 +34,7 @@ /* body dynbuf sizes */ #define CW_PAUSE_BUF_CHUNK (16 * 1024) /* when content decoding, write data in chunks */ -#define CW_PAUSE_DEC_WRITE_CHUNK (4096) +#define CW_PAUSE_DEC_WRITE_CHUNK 4096 struct cw_pause_buf { struct cw_pause_buf *next; diff --git a/lib/doh.c b/lib/doh.c index 5401256bf8..e22fde8ef4 100644 --- a/lib/doh.c +++ b/lib/doh.c @@ -884,13 +884,13 @@ static void doh_show(struct Curl_easy *data, } #ifdef USE_HTTPSRR for(i = 0; i < d->numhttps_rrs; i++) { -# if defined(DEBUGBUILD) && defined(CURLVERBOSE) +#if defined(DEBUGBUILD) && defined(CURLVERBOSE) doh_print_buf(data, "DoH HTTPS", d->https_rrs[i].val, d->https_rrs[i].len); -# else +#else infof(data, "DoH HTTPS RR: length %d", d->https_rrs[i].len); -# endif - } #endif + } +#endif /* USE_HTTPSRR */ for(i = 0; i < d->numcname; i++) { infof(data, "CNAME: %s", curlx_dyn_ptr(&d->cname[i])); } @@ -1268,12 +1268,12 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data, goto error; } infof(data, "Some HTTPS RR to process"); -# if defined(DEBUGBUILD) && defined(CURLVERBOSE) +#if defined(DEBUGBUILD) && defined(CURLVERBOSE) doh_print_httpsrr(data, hrr); -# endif +#endif dns->hinfo = hrr; } -#endif +#endif /* USE_HTTPSRR */ /* and add the entry to the cache */ data->state.async.dns = dns; result = Curl_dnscache_add(data, dns); diff --git a/lib/dynhds.h b/lib/dynhds.h index 2cfa290571..ee728d1c3e 100644 --- a/lib/dynhds.h +++ b/lib/dynhds.h @@ -50,7 +50,7 @@ struct dynhds { int opts; }; -#define DYNHDS_OPT_NONE (0) +#define DYNHDS_OPT_NONE 0 #define DYNHDS_OPT_LOWERCASE (1 << 0) /** diff --git a/lib/ftp.c b/lib/ftp.c index 5110ee1397..a7be74846a 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -86,7 +86,7 @@ #ifndef CURLVERBOSE #define FTP_CSTATE(c) ((void)(c), "") -#else /* !CURLVERBOSE */ +#else /* for tracing purposes */ static const char * const ftp_state_names[] = { "STOP", diff --git a/lib/headers.h b/lib/headers.h index adb03af75b..e031c5aa14 100644 --- a/lib/headers.h +++ b/lib/headers.h @@ -30,7 +30,7 @@ struct Curl_header_store { struct Curl_llist_node node; char *name; /* points into 'buffer' */ - char *value; /* points into 'buffer */ + char *value; /* points into 'buffer' */ int request; /* 0 is the first request, then 1.. 2.. */ unsigned char type; /* CURLH_* defines */ char buffer[1]; /* this is the raw header blob */ diff --git a/lib/hsts.c b/lib/hsts.c index 15d4207548..8413ea7fed 100644 --- a/lib/hsts.c +++ b/lib/hsts.c @@ -318,7 +318,7 @@ static CURLcode hsts_out(struct stsentry *sts, FILE *fp) } else curl_mfprintf(fp, "%s%s \"%s\"\n", - sts->includeSubDomains ? ".": "", sts->host, UNLIMITED); + sts->includeSubDomains ? "." : "", sts->host, UNLIMITED); return CURLE_OK; } diff --git a/lib/http.c b/lib/http.c index 39f0a0d194..7403bed5ad 100644 --- a/lib/http.c +++ b/lib/http.c @@ -4062,7 +4062,7 @@ static CURLcode http_on_response(struct Curl_easy *data, goto out; if(k->httpcode >= 300) { - if((!data->req.authneg) && !conn->bits.close && + if(!data->req.authneg && !conn->bits.close && !Curl_creader_will_rewind(data)) { /* * General treatment of errors when about to send data. Including : diff --git a/lib/http1.h b/lib/http1.h index 124d32e373..c2894613de 100644 --- a/lib/http1.h +++ b/lib/http1.h @@ -29,7 +29,7 @@ #include "bufq.h" #include "http.h" -#define H1_PARSE_OPT_NONE (0) +#define H1_PARSE_OPT_NONE 0 #define H1_PARSE_OPT_STRICT (1 << 0) #define H1_PARSE_DEFAULT_MAX_LINE_LEN DYN_HTTP_REQUEST diff --git a/lib/http_chunks.c b/lib/http_chunks.c index 9b38a3780c..db650b1e1e 100644 --- a/lib/http_chunks.c +++ b/lib/http_chunks.c @@ -33,12 +33,12 @@ #include "curlx/strparse.h" /* - * Chunk format (simplified): - * - * [ chunk extension ] CRLF - * CRLF - * - * Highlights from RFC2616 section 3.6 say: + Chunk format (simplified): + + [ chunk extension ] CRLF + CRLF + + Highlights from RFC2616 section 3.6 say: The chunked encoding modifies the body of a message in order to transfer it as a series of chunks, each with its own size indicator, @@ -460,7 +460,7 @@ const struct Curl_cwtype Curl_httpchunk_unencoder = { }; /* max length of an HTTP chunk that we want to generate */ -#define CURL_CHUNKED_MINLEN (1024) +#define CURL_CHUNKED_MINLEN 1024 #define CURL_CHUNKED_MAXLEN (64 * 1024) struct chunked_reader { @@ -583,7 +583,7 @@ static CURLcode add_chunk(struct Curl_easy *data, if(!result) result = Curl_bufq_cwrite(&ctx->chunkbuf, "\r\n", 2, &n); CURL_TRC_READ(data, "http_chunk, made chunk of %zu bytes -> %d", - nread, result); + nread, result); if(result) return result; } diff --git a/lib/imap.c b/lib/imap.c index 414ee32466..06244b6dac 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -1141,7 +1141,7 @@ static CURLcode imap_state_auth_resp(struct Curl_easy *data, imap_state(data, imapc, IMAP_STOP); /* Authenticated */ break; case SASL_IDLE: /* No mechanism left after cancellation */ - if((!imapc->login_disabled) && (imapc->preftype & IMAP_TYPE_CLEARTEXT)) + if(!imapc->login_disabled && (imapc->preftype & IMAP_TYPE_CLEARTEXT)) /* Perform clear text authentication */ result = imap_perform_login(data, imapc, data->conn); else { diff --git a/lib/ldap.c b/lib/ldap.c index e0da4a0776..5068311953 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -44,24 +44,24 @@ */ #ifdef USE_WIN32_LDAP /* Use Windows LDAP implementation. */ -# include -/* Undefine indirect symbols conflicting with BoringSSL. */ -#undef X509_NAME -#undef X509_EXTENSIONS -#undef PKCS7_ISSUER_AND_SERIAL -#undef PKCS7_SIGNER_INFO -#undef OCSP_REQUEST -#undef OCSP_RESPONSE -# include +# include +/* Undefine indirect symbols conflicting with BoringSSL/AWS-LC. */ +# undef X509_NAME +# undef X509_EXTENSIONS +# undef PKCS7_ISSUER_AND_SERIAL +# undef PKCS7_SIGNER_INFO +# undef OCSP_REQUEST +# undef OCSP_RESPONSE +# include #else -# define LDAP_DEPRECATED 1 /* Be sure ldap_init() is defined. */ -# ifdef HAVE_LBER_H -# include -# endif -# include -# if defined(HAVE_LDAP_SSL) && defined(HAVE_LDAP_SSL_H) -# include -# endif /* HAVE_LDAP_SSL && HAVE_LDAP_SSL_H */ +# define LDAP_DEPRECATED 1 /* Be sure ldap_init() is defined. */ +# ifdef HAVE_LBER_H +# include +# endif +# include +# if defined(HAVE_LDAP_SSL) && defined(HAVE_LDAP_SSL_H) +# include +# endif /* HAVE_LDAP_SSL && HAVE_LDAP_SSL_H */ #endif #include "cfilters.h" @@ -80,7 +80,7 @@ #define FREE_ON_WINLDAP(x) curlx_free(x) #define curl_ldap_num_t ULONG #else -#define FREE_ON_WINLDAP(x) +#define FREE_ON_WINLDAP(x) do {} while(0) #define curl_ldap_num_t int #endif diff --git a/lib/mprintf.c b/lib/mprintf.c index 8f81f033dc..f9345da4c0 100644 --- a/lib/mprintf.c +++ b/lib/mprintf.c @@ -33,7 +33,7 @@ #define MAX_SEGMENTS 128 /* number of output segments */ #ifdef __AMIGA__ -# undef FORMAT_INT +#undef FORMAT_INT #endif /* Lower-case digits. */ diff --git a/lib/setopt.c b/lib/setopt.c index e6476dfaf3..1bb75131ef 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -1415,7 +1415,7 @@ static CURLcode setopt_slist(struct Curl_easy *data, CURLoption option, #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \ !defined(CURL_DISABLE_IMAP) -# ifndef CURL_DISABLE_MIME +#ifndef CURL_DISABLE_MIME static CURLcode setopt_mimepost(struct Curl_easy *data, curl_mime *mimep) { /* @@ -1469,7 +1469,7 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option, #endif /* !CURL_DISABLE_HTTP */ #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \ !defined(CURL_DISABLE_IMAP) -# ifndef CURL_DISABLE_MIME +#ifndef CURL_DISABLE_MIME case CURLOPT_MIMEPOST: result = setopt_mimepost(data, va_arg(param, curl_mime *)); break; diff --git a/lib/smtp.c b/lib/smtp.c index 23590398f9..93f1211ab0 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -227,8 +227,7 @@ static CURLcode smtp_parse_custom_request(struct Curl_easy *data, * * Parameters: * - * conn [in] - The connection handle. - * fqma [in] - The fully qualified mailbox address (which may or + * fqma [in] - The fully qualified mailbox address (which may or * may not contain UTF-8 characters). * address [in/out] - A new allocated buffer which holds the local * address part of the mailbox. This buffer must be @@ -835,7 +834,7 @@ static CURLcode smtp_perform_command(struct Curl_easy *data, whether the hostname is encoded using IDN ACE */ bool utf8 = FALSE; - if((!smtp->custom) || (!smtp->custom[0])) { + if(!smtp->custom || !smtp->custom[0]) { char *address = NULL; struct hostname host = { NULL, NULL, NULL, NULL }; const char *suffix = ""; diff --git a/lib/socks_gssapi.c b/lib/socks_gssapi.c index 21722f0720..962fcd05b2 100644 --- a/lib/socks_gssapi.c +++ b/lib/socks_gssapi.c @@ -168,8 +168,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, (void)curlx_nonblock(sock, FALSE); - /* As long as we need to keep sending some context info, and there is no */ - /* errors, keep sending it... */ + /* As long as we need to keep sending some context info, and there is no + * errors, keep sending it... */ for(;;) { gss_major_status = Curl_gss_init_sec_context(data, &gss_minor_status, @@ -515,7 +515,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, (void)curlx_nonblock(sock, TRUE); infof(data, "SOCKS5 access with%s protection granted.", - (socksreq[0] == 0) ? "out GSS-API data": + (socksreq[0] == 0) ? "out GSS-API data" : ((socksreq[0] == 1) ? " GSS-API integrity" : " GSS-API confidentiality")); diff --git a/lib/socks_sspi.c b/lib/socks_sspi.c index cec410fe60..46727b3744 100644 --- a/lib/socks_sspi.c +++ b/lib/socks_sspi.c @@ -550,7 +550,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, (void)curlx_nonblock(sock, TRUE); infof(data, "SOCKS5 access with%s protection granted BUT NOT USED.", - (socksreq[0] == 0) ? "out GSS-API data": + (socksreq[0] == 0) ? "out GSS-API data" : ((socksreq[0] == 1) ? " GSS-API integrity" : " GSS-API confidentiality")); diff --git a/lib/telnet.c b/lib/telnet.c index d1b1d8fc5e..f14aa9c9be 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -1279,8 +1279,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) } /* Tell Winsock what events we want to listen to */ - if(WSAEventSelect(sockfd, event_handle, FD_READ | FD_CLOSE) == - SOCKET_ERROR) { + if(WSAEventSelect(sockfd, event_handle, FD_READ | FD_CLOSE) != 0) { WSACloseEvent(event_handle); return CURLE_RECV_ERROR; } @@ -1378,7 +1377,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) case WAIT_OBJECT_0: { events.lNetworkEvents = 0; - if(WSAEnumNetworkEvents(sockfd, event_handle, &events) == SOCKET_ERROR) { + if(WSAEnumNetworkEvents(sockfd, event_handle, &events) != 0) { err = SOCKERRNO; if(err != SOCKEINPROGRESS) { infof(data, "WSAEnumNetworkEvents failed (%d)", err); diff --git a/lib/transfer.c b/lib/transfer.c index 32c31c6e93..183aee0f84 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -127,16 +127,14 @@ bool Curl_meets_timecondition(struct Curl_easy *data, time_t timeofdoc) case CURL_TIMECOND_IFMODSINCE: default: if(timeofdoc <= data->set.timevalue) { - infof(data, - "The requested document is not new enough"); + infof(data, "The requested document is not new enough"); data->info.timecond = TRUE; return FALSE; } break; case CURL_TIMECOND_IFUNMODSINCE: if(timeofdoc >= data->set.timevalue) { - infof(data, - "The requested document is not old enough"); + infof(data, "The requested document is not old enough"); data->info.timecond = TRUE; return FALSE; } diff --git a/lib/url.c b/lib/url.c index f3b24c9de2..b085df1a4d 100644 --- a/lib/url.c +++ b/lib/url.c @@ -423,8 +423,8 @@ void Curl_init_userdefined(struct Curl_easy *data) #endif #ifndef CURL_DISABLE_FTP set->wildcard_enabled = FALSE; - set->chunk_bgn = ZERO_NULL; - set->chunk_end = ZERO_NULL; + set->chunk_bgn = ZERO_NULL; + set->chunk_end = ZERO_NULL; set->fnmatch = ZERO_NULL; #endif set->tcp_keepalive = FALSE; diff --git a/lib/urlapi.c b/lib/urlapi.c index d6a790b06e..18cdb43745 100644 --- a/lib/urlapi.c +++ b/lib/urlapi.c @@ -118,8 +118,8 @@ static const char *find_host_sep(const char *url) } /* convert CURLcode to CURLUcode */ -#define cc2cu(x) ((x) == CURLE_TOO_LARGE ? CURLUE_TOO_LARGE : \ - CURLUE_OUT_OF_MEMORY) +#define cc2cu(x) \ + ((x) == CURLE_TOO_LARGE ? CURLUE_TOO_LARGE : CURLUE_OUT_OF_MEMORY) /* urlencode_str() writes data into an output dynbuf and URL-encodes the * spaces in the source URL accordingly. @@ -1440,9 +1440,9 @@ static CURLUcode urlget_url(const CURLU *u, char **part, unsigned int flags) if(u->scheme && curl_strequal("file", u->scheme)) { url = curl_maprintf("file://%s%s%s%s%s", u->path, - show_query ? "?": "", + show_query ? "?" : "", u->query ? u->query : "", - show_fragment ? "#": "", + show_fragment ? "#" : "", u->fragment ? u->fragment : ""); } else if(!u->host) @@ -1517,18 +1517,18 @@ static CURLUcode urlget_url(const CURLU *u, char **part, unsigned int flags) url = curl_maprintf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", schemebuf, u->user ? u->user : "", - u->password ? ":": "", + u->password ? ":" : "", u->password ? u->password : "", options ? ";" : "", options ? options : "", - (u->user || u->password || options) ? "@": "", + (u->user || u->password || options) ? "@" : "", allochost ? allochost : u->host, - port ? ":": "", + port ? ":" : "", port ? port : "", u->path ? u->path : "/", - show_query ? "?": "", + show_query ? "?" : "", u->query ? u->query : "", - show_fragment ? "#": "", + show_fragment ? "#" : "", u->fragment ? u->fragment : ""); curlx_free(allochost); } diff --git a/lib/urldata.h b/lib/urldata.h index 71e5d6f4a1..e87e815d86 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -54,11 +54,11 @@ #ifdef USE_ECH /* CURLECH_ bits for the tls_ech option */ -# define CURLECH_DISABLE (1 << 0) -# define CURLECH_GREASE (1 << 1) -# define CURLECH_ENABLE (1 << 2) -# define CURLECH_HARD (1 << 3) -# define CURLECH_CLA_CFG (1 << 4) +#define CURLECH_DISABLE (1 << 0) +#define CURLECH_GREASE (1 << 1) +#define CURLECH_ENABLE (1 << 2) +#define CURLECH_HARD (1 << 3) +#define CURLECH_CLA_CFG (1 << 4) #endif #ifndef CURL_DISABLE_WEBSOCKETS @@ -179,14 +179,14 @@ typedef CURLcode (Curl_recv)(struct Curl_easy *data, /* transfer */ #include "cf-socket.h" #ifdef HAVE_GSSAPI -# ifdef HAVE_GSSGNU -# include -# elif defined(HAVE_GSSAPI_H) -# include -# else /* MIT Kerberos */ -# include -# include /* for GSS_C_CHANNEL_BOUND_FLAG, in 1.19+ */ -# endif +# ifdef HAVE_GSSGNU +# include +# elif defined(HAVE_GSSAPI_H) +# include +# else /* MIT Kerberos */ +# include +# include /* for GSS_C_CHANNEL_BOUND_FLAG in 1.19+ */ +# endif #endif #ifdef USE_LIBSSH2 diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index 65c78e6848..61e7d3452e 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -2534,7 +2534,7 @@ static CURLcode cf_ngtcp2_on_session_reuse(struct Curl_cfilter *cf, #endif #if defined(USE_GNUTLS) || defined(USE_WOLFSSL) || \ (defined(USE_OPENSSL) && defined(HAVE_OPENSSL_EARLYDATA)) - if((!ctx->earlydata_max)) { + if(!ctx->earlydata_max) { CURL_TRC_CF(data, cf, "SSL session does not allow earlydata"); } else if(!Curl_alpn_contains_proto(alpns, scs->alpn)) { diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index 5d981cb2e6..e5913eaf59 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -53,10 +53,10 @@ /* HTTP/3 error values defined in RFC 9114, ch. 8.1 */ #define CURL_H3_NO_ERROR 0x0100 -#define QUIC_MAX_STREAMS (100) +#define QUIC_MAX_STREAMS 100 -#define H3_STREAM_WINDOW_SIZE (128 * 1024) -#define H3_STREAM_CHUNK_SIZE (16 * 1024) +#define H3_STREAM_WINDOW_SIZE (1024 * 128) +#define H3_STREAM_CHUNK_SIZE (1024 * 16) /* The pool keeps spares around and half of a full stream windows seems good. * More does not seem to improve performance. The benefit of the pool is that * stream buffer to not keep spares. Memory consumption goes down when streams diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index a5d58ec731..9e4ce40d8d 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -749,13 +749,13 @@ static int myssh_in_AUTHLIST(struct Curl_easy *data, if(sshc->auth_methods) infof(data, "SSH authentication methods available: %s%s%s%s", sshc->auth_methods & SSH_AUTH_METHOD_PUBLICKEY ? - "public key, ": "", + "public key, " : "", sshc->auth_methods & SSH_AUTH_METHOD_GSSAPI_MIC ? "GSSAPI, " : "", sshc->auth_methods & SSH_AUTH_METHOD_INTERACTIVE ? "keyboard-interactive, " : "", sshc->auth_methods & SSH_AUTH_METHOD_PASSWORD ? - "password": ""); + "password" : ""); /* For public key auth we need either the private key or CURLSSH_AUTH_AGENT. */ if((sshc->auth_methods & SSH_AUTH_METHOD_PUBLICKEY) && diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index 15b7c056dd..8c14a9c987 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -699,10 +699,10 @@ static CURLcode ssh_force_knownhost_key_type(struct Curl_easy *data, rc = libssh2_session_method_pref(sshc->ssh_session, LIBSSH2_METHOD_HOSTKEY, hostkey_method); if(rc) { - char *errmsg = NULL; + char *err_msg = NULL; int errlen; - libssh2_session_last_error(sshc->ssh_session, &errmsg, &errlen, 0); - failf(data, "libssh2 method '%s' failed: %s", hostkey_method, errmsg); + libssh2_session_last_error(sshc->ssh_session, &err_msg, &errlen, 0); + failf(data, "libssh2 method '%s' failed: %s", hostkey_method, err_msg); result = libssh2_session_error_to_CURLE(rc); } } diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index d6093cfe30..9887d98c25 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -55,7 +55,9 @@ #include "x509asn1.h" /* Enable GnuTLS debugging by defining GTLSDEBUG */ -/*#define GTLSDEBUG */ +#if 0 +#define GTLSDEBUG +#endif #ifdef GTLSDEBUG static void tls_log_func(int level, const char *str) @@ -723,7 +725,7 @@ CURLcode Curl_gtls_cache_session(struct Curl_cfilter *cf, "and store in cache", sdata_len, alpn ? alpn : "-", earlydata_max); if(quic_tp && quic_tp_len) { - qtp_clone = curlx_memdup0((char *)quic_tp, quic_tp_len); + qtp_clone = curlx_memdup0((const char *)quic_tp, quic_tp_len); if(!qtp_clone) { curlx_free(sdata); return CURLE_OUT_OF_MEMORY; diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 0834109ae7..f4273008ff 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -1530,7 +1530,7 @@ static CURLcode client_cert(struct Curl_easy *data, return CURLE_BAD_FUNCTION_ARGUMENT; } - if((!key_file) && (!key_blob)) { + if(!key_file && !key_blob) { key_file = cert_file; key_blob = cert_blob; } @@ -2724,7 +2724,7 @@ CURLcode Curl_ossl_add_session(struct Curl_cfilter *cf, earlydata_max = SSL_SESSION_get_max_early_data(session); #endif if(quic_tp && quic_tp_len) { - qtp_clone = curlx_memdup0((char *)quic_tp, quic_tp_len); + qtp_clone = curlx_memdup0((const char *)quic_tp, quic_tp_len); if(!qtp_clone) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -3472,14 +3472,14 @@ static CURLcode ossl_init_ech(struct ossl_ctx *octx, if(data->set.tls_ech & CURLECH_GREASE) { infof(data, "ECH: will GREASE ClientHello"); -# ifdef HAVE_BORINGSSL_LIKE +#ifdef HAVE_BORINGSSL_LIKE SSL_set_enable_ech_grease(octx->ssl, 1); -# else +#else SSL_set_options(octx->ssl, SSL_OP_ECH_GREASE); -# endif +#endif } else if(data->set.tls_ech & CURLECH_CLA_CFG) { -# ifdef HAVE_BORINGSSL_LIKE +#ifdef HAVE_BORINGSSL_LIKE /* have to do base64 decode here for BoringSSL */ const char *b64 = data->set.str[STRING_ECH_CONFIG]; @@ -3503,7 +3503,7 @@ static CURLcode ossl_init_ech(struct ossl_ctx *octx, } curlx_free(ech_config); trying_ech_now = 1; -# else +#else ech_config = (unsigned char *)data->set.str[STRING_ECH_CONFIG]; if(!ech_config) { infof(data, "ECH: ECHConfig from command line empty"); @@ -3517,7 +3517,7 @@ static CURLcode ossl_init_ech(struct ossl_ctx *octx, } else trying_ech_now = 1; -# endif +#endif /* HAVE_BORINGSSL_LIKE */ infof(data, "ECH: ECHConfig from command line"); } else { @@ -3558,12 +3558,12 @@ static CURLcode ossl_init_ech(struct ossl_ctx *octx, Curl_resolv_unlink(data, &dns); } } -# ifdef HAVE_BORINGSSL_LIKE +#ifdef HAVE_BORINGSSL_LIKE if(trying_ech_now && outername) { infof(data, "ECH: setting public_name not supported with BoringSSL"); return CURLE_SSL_CONNECT_ERROR; } -# else +#else if(trying_ech_now && outername) { infof(data, "ECH: inner: '%s', outer: '%s'", peer->hostname ? peer->hostname : "NULL", outername); @@ -3575,7 +3575,7 @@ static CURLcode ossl_init_ech(struct ossl_ctx *octx, return CURLE_SSL_CONNECT_ERROR; } } -# endif /* HAVE_BORINGSSL_LIKE */ +#endif /* HAVE_BORINGSSL_LIKE */ if(trying_ech_now && SSL_set_min_proto_version(octx->ssl, TLS1_3_VERSION) != 1) { infof(data, "ECH: cannot force TLSv1.3 [ERROR]"); @@ -4085,27 +4085,27 @@ static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL *ssl, CURLcode result = CURLE_OK; size_t rcl = 0; int rv = 1; -# ifndef HAVE_BORINGSSL_LIKE +#ifndef HAVE_BORINGSSL_LIKE char *inner = NULL; uint8_t *rcs = NULL; char *outer = NULL; -# else +#else const char *inner = NULL; const uint8_t *rcs = NULL; const char *outer = NULL; size_t out_name_len = 0; int servername_type = 0; -# endif +#endif /* nothing to trace if not doing ECH */ if(!ECH_ENABLED(data)) return; -# ifndef HAVE_BORINGSSL_LIKE +#ifndef HAVE_BORINGSSL_LIKE rv = SSL_ech_get1_retry_config(ssl, &rcs, &rcl); -# else +#else SSL_get0_ech_retry_configs(ssl, &rcs, &rcl); rv = (int)rcl; -# endif +#endif if(rv && rcs) { char *b64str = NULL; @@ -4131,9 +4131,9 @@ static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL *ssl, } else infof(data, "ECH: no retry_configs (rv = %d)", rv); -# ifndef HAVE_BORINGSSL_LIKE +#ifndef HAVE_BORINGSSL_LIKE OPENSSL_free((void *)rcs); -# endif +#endif return; } @@ -4250,11 +4250,11 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, #endif #ifdef HAVE_SSL_SET1_ECH_CONFIG_LIST else if((lib == ERR_LIB_SSL) && -# ifndef HAVE_BORINGSSL_LIKE +#ifndef HAVE_BORINGSSL_LIKE (reason == SSL_R_ECH_REQUIRED)) { -# else +#else (reason == SSL_R_ECH_REJECTED)) { -# endif +#endif /* HAVE_BORINGSSL_LIKE */ /* trace retry_configs if we got some */ ossl_trace_ech_retry_configs(data, octx->ssl, reason); diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index 7eba784368..40b6bfd2a2 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -32,7 +32,7 @@ #ifdef USE_SCHANNEL #ifndef USE_WINDOWS_SSPI -#error "cannot compile SCHANNEL support without SSPI." +#error "cannot compile Schannel support without SSPI." #endif #include "schannel.h" @@ -200,7 +200,7 @@ static CURLcode schannel_set_ssl_version_min_max(DWORD *enabled_protocols, return CURLE_OK; } -#define CIPHEROPTION(x) {#x, x} +#define CIPHEROPTION(x) { #x, x } struct algo { const char *name; @@ -261,7 +261,7 @@ static const struct algo algs[] = { #ifdef CALG_ECDH_EPHEM CIPHEROPTION(CALG_ECDH_EPHEM), #endif - {NULL, 0}, + { NULL, 0 }, }; static int get_alg_id_by_name(const char *name) @@ -501,8 +501,8 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf, if(fInCert || blob) { /* Reading a .P12 or .pfx file, like the example at bottom of - https://learn.microsoft.com/archive/msdn-technet-forums/3e7bc95f-b21a-4bcd-bd2c-7f996718cae5 - */ + * https://learn.microsoft.com/archive/msdn-technet-forums/3e7bc95f-b21a-4bcd-bd2c-7f996718cae5 + */ CRYPT_DATA_BLOB datablob; WCHAR *pszPassword; size_t pwd_len = 0; @@ -525,8 +525,7 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf, continue_reading = fseek(fInCert, 0, SEEK_SET) == 0; if(continue_reading && (certsize < CURL_MAX_INPUT_LENGTH)) certdata = curlx_malloc(certsize + 1); - if((!certdata) || - ((int) fread(certdata, certsize, 1, fInCert) != 1)) + if(!certdata || ((int)fread(certdata, certsize, 1, fInCert) != 1)) continue_reading = FALSE; curlx_fclose(fInCert); if(!continue_reading) { @@ -1070,8 +1069,8 @@ static CURLcode schannel_pkp_pin_peer_pubkey(struct Curl_cfilter *cf, sspi_status = Curl_pSecFn->QueryContextAttributes(&backend->ctxt->ctxt_handle, - SECPKG_ATTR_REMOTE_CERT_CONTEXT, - &pCertContextServer); + SECPKG_ATTR_REMOTE_CERT_CONTEXT, + &pCertContextServer); if((sspi_status != SEC_E_OK) || !pCertContextServer) { char buffer[STRERROR_LEN]; @@ -1527,8 +1526,8 @@ static CURLcode schannel_connect_step3(struct Curl_cfilter *cf, if(backend->use_alpn) { sspi_status = Curl_pSecFn->QueryContextAttributes(&backend->ctxt->ctxt_handle, - SECPKG_ATTR_APPLICATION_PROTOCOL, - &alpn_result); + SECPKG_ATTR_APPLICATION_PROTOCOL, + &alpn_result); if(sspi_status != SEC_E_OK) { failf(data, "schannel: failed to retrieve ALPN result"); @@ -1573,8 +1572,8 @@ static CURLcode schannel_connect_step3(struct Curl_cfilter *cf, int certs_count = 0; sspi_status = Curl_pSecFn->QueryContextAttributes(&backend->ctxt->ctxt_handle, - SECPKG_ATTR_REMOTE_CERT_CONTEXT, - &ccert_context); + SECPKG_ATTR_REMOTE_CERT_CONTEXT, + &ccert_context); if((sspi_status != SEC_E_OK) || !ccert_context) { failf(data, "schannel: failed to retrieve remote cert context"); @@ -1677,9 +1676,9 @@ enum schannel_renegotiate_caller_t { incomplete. In that case, we remain in the renegotiation (connecting) stage and future calls to schannel_recv and schannel_send must call this function first to complete the renegotiation. */ -static CURLcode -schannel_recv_renegotiate(struct Curl_cfilter *cf, struct Curl_easy *data, - enum schannel_renegotiate_caller_t caller) +static CURLcode schannel_recv_renegotiate( + struct Curl_cfilter *cf, struct Curl_easy *data, + enum schannel_renegotiate_caller_t caller) { CURLcode result; curl_socket_t sockfd; @@ -2100,9 +2099,9 @@ static CURLcode schannel_recv(struct Curl_cfilter *cf, struct Curl_easy *data, /* read encrypted data from socket */ result = Curl_conn_cf_recv(cf->next, data, - (char *)(backend->encdata_buffer + - backend->encdata_offset), - size, &nread); + (char *)(backend->encdata_buffer + + backend->encdata_offset), + size, &nread); if(result) { if(result == CURLE_AGAIN) SCH_DEV(infof(data, "schannel: recv returned CURLE_AGAIN")); @@ -2389,7 +2388,7 @@ static CURLcode schannel_shutdown(struct Curl_cfilter *cf, InitSecBufferDesc(&BuffDesc, &Buffer, 1); sspi_status = Curl_pSecFn->ApplyControlToken(&backend->ctxt->ctxt_handle, - &BuffDesc); + &BuffDesc); if(sspi_status != SEC_E_OK) { char buffer[STRERROR_LEN]; diff --git a/lib/vtls/schannel.h b/lib/vtls/schannel.h index 78db502b9e..3cf9487a75 100644 --- a/lib/vtls/schannel.h +++ b/lib/vtls/schannel.h @@ -29,8 +29,8 @@ #ifdef USE_SCHANNEL #include -#include "../curl_sspi.h" +#include "../curl_sspi.h" #include "../cfilters.h" #include "../urldata.h" diff --git a/lib/vtls/schannel_verify.c b/lib/vtls/schannel_verify.c index 5129b8b04d..0b5cd2d662 100644 --- a/lib/vtls/schannel_verify.c +++ b/lib/vtls/schannel_verify.c @@ -31,7 +31,7 @@ #ifdef USE_SCHANNEL #ifndef USE_WINDOWS_SSPI -#error "cannot compile SCHANNEL support without SSPI." +#error "cannot compile Schannel support without SSPI." #endif #include "schannel.h" diff --git a/lib/vtls/vtls.h b/lib/vtls/vtls.h index bf19572fc6..8b04c11101 100644 --- a/lib/vtls/vtls.h +++ b/lib/vtls/vtls.h @@ -49,8 +49,8 @@ struct dynbuf; #define SSLSUPP_ISSUERCERT_BLOB (1 << 14) /* CURLOPT_ISSUERCERT_BLOB */ #ifdef USE_ECH -# include "../curlx/base64.h" -# define ECH_ENABLED(__data__) \ +#include "../curlx/base64.h" +#define ECH_ENABLED(__data__) \ (__data__->set.tls_ech && !(__data__->set.tls_ech & CURLECH_DISABLE)) #endif /* USE_ECH */ diff --git a/lib/vtls/vtls_int.h b/lib/vtls/vtls_int.h index c2a44a3a33..bbcf905035 100644 --- a/lib/vtls/vtls_int.h +++ b/lib/vtls/vtls_int.h @@ -102,12 +102,12 @@ typedef enum { ssl_earlydata_rejected } ssl_earlydata_state; -#define CURL_SSL_IO_NEED_NONE (0) +#define CURL_SSL_IO_NEED_NONE 0 #define CURL_SSL_IO_NEED_RECV (1 << 0) #define CURL_SSL_IO_NEED_SEND (1 << 1) /* Max earlydata payload we want to send */ -#define CURL_SSL_EARLY_MAX (64 * 1024) +#define CURL_SSL_EARLY_MAX (64 * 1024) /* Information in each SSL cfilter context: cf->ctx */ struct ssl_connect_data { diff --git a/lib/vtls/vtls_scache.c b/lib/vtls/vtls_scache.c index 0149b51869..60300c7646 100644 --- a/lib/vtls/vtls_scache.c +++ b/lib/vtls/vtls_scache.c @@ -1204,7 +1204,6 @@ CURLcode Curl_ssl_session_export(struct Curl_easy *data, ++ntickets; n = Curl_node_next(n); } - } r = CURLE_OK; CURL_TRC_SSLS(data, "exported %zu session tickets for %zu peers", diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index d0311facb9..938acba3e1 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -443,7 +443,7 @@ CURLcode Curl_wssl_cache_session(struct Curl_cfilter *cf, goto out; } if(quic_tp && quic_tp_len) { - qtp_clone = curlx_memdup0((char *)quic_tp, quic_tp_len); + qtp_clone = curlx_memdup0((const char *)quic_tp, quic_tp_len); if(!qtp_clone) { curlx_free(sdata); return CURLE_OUT_OF_MEMORY; diff --git a/lib/vtls/x509asn1.c b/lib/vtls/x509asn1.c index 5c3a727e63..1efb6ae1cb 100644 --- a/lib/vtls/x509asn1.c +++ b/lib/vtls/x509asn1.c @@ -556,7 +556,7 @@ static CURLcode GTime2str(struct dynbuf *store, "%.4s-%.2s-%.2s %.2s:%.2s:%c%c%s%.*s%s%.*s", beg, beg + 4, beg + 6, beg + 8, beg + 10, sec1, sec2, - fracl ? ".": "", (int)fracl, fracp, + fracl ? "." : "", (int)fracl, fracp, sep, (int)tzl, tzp); } diff --git a/m4/curl-override.m4 b/m4/curl-override.m4 index e84b4ca5fa..a8ae55fcaa 100644 --- a/m4/curl-override.m4 +++ b/m4/curl-override.m4 @@ -82,9 +82,9 @@ m4_define([AC_LANG_FUNC_LINK_TRY(C)], [ #define $1 innocuous_$1 #ifdef __STDC__ -# include +# include #else -# include +# include #endif #undef $1 #ifdef __cplusplus diff --git a/scripts/cd2cd b/scripts/cd2cd index d593e9a579..c297d5e0bd 100755 --- a/scripts/cd2cd +++ b/scripts/cd2cd @@ -69,7 +69,7 @@ sub outseealso { my @o; push @o, ".SH SEE ALSO\n"; for my $s (sort @sa) { - push @o, sprintf "%s.BR $s", $comma ? ",\n": ""; + push @o, sprintf "%s.BR $s", $comma ? ",\n" : ""; $comma = 1; } push @o, "\n"; diff --git a/scripts/cd2nroff b/scripts/cd2nroff index e97d1299dd..adc66216d7 100755 --- a/scripts/cd2nroff +++ b/scripts/cd2nroff @@ -89,7 +89,7 @@ sub outseealso { my @o; push @o, ".SH SEE ALSO\n"; for my $s (sort @sa) { - push @o, sprintf "%s.BR $s", $comma ? ",\n": ""; + push @o, sprintf "%s.BR $s", $comma ? ",\n" : ""; $comma = 1; } push @o, "\n"; diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index f5bbab69e7..14d94d09bb 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -273,7 +273,7 @@ sub readlocalfile { sub checkwarn { my ($name, $num, $col, $file, $line, $msg, $error) = @_; - my $w=$error?"error":"warning"; + my $w=$error ? "error" : "warning"; my $nowarn=0; #if(!$warnings{$name}) { diff --git a/scripts/ciconfig.pl b/scripts/ciconfig.pl index 95ce0fb877..a02dfb768f 100755 --- a/scripts/ciconfig.pl +++ b/scripts/ciconfig.pl @@ -170,14 +170,14 @@ scanjobs(); print "Used configure options (with / without)\n"; for my $w (sort keys %used) { printf " %s: %d %d%s\n", $w, $with{$w}, $without{$w}, - $defaulton{$w} ? " (auto)":""; + $defaulton{$w} ? " (auto)" : ""; } print "Never used configure options\n"; for my $w (sort keys %avail) { if(!$used{$w}) { printf " %s%s\n", $w, - $defaulton{$w} ? " (auto)":""; + $defaulton{$w} ? " (auto)" : ""; } } diff --git a/scripts/cijobs.pl b/scripts/cijobs.pl index 2be9d2565c..3939867f3c 100755 --- a/scripts/cijobs.pl +++ b/scripts/cijobs.pl @@ -98,7 +98,7 @@ sub githubactions { # matrix job #print "name: $1\n"; $job{'name'} = $1; - $j += ($m?$m:1); + $j += ($m ? $m : 1); } elsif($_ =~ /install: (.*)/) { $job{'install'} = $1; @@ -258,22 +258,22 @@ sub appveyor { $job{'config'} = $1; } elsif($_ =~ /^ OPENSSL: \'(.*)\'/) { - $job{'openssl'} = $1 eq "ON" ? "true": "false"; + $job{'openssl'} = $1 eq "ON" ? "true" : "false"; } elsif($_ =~ /^ SCHANNEL: \'(.*)\'/) { - $job{'schannel'} = $1 eq "ON" ? "true": "false"; + $job{'schannel'} = $1 eq "ON" ? "true" : "false"; } elsif($_ =~ /^ ENABLE_UNICODE: \'(.*)\'/) { - $job{'unicode'} = $1 eq "ON" ? "true": "false"; + $job{'unicode'} = $1 eq "ON" ? "true" : "false"; } elsif($_ =~ /^ HTTP_ONLY: \'(.*)\'/) { - $job{'http-only'} = $1 eq "ON" ? "true": "false"; + $job{'http-only'} = $1 eq "ON" ? "true" : "false"; } elsif($_ =~ /^ TESTING: \'(.*)\'/) { - $job{'testing'} = $1 eq "ON" ? "true": "false"; + $job{'testing'} = $1 eq "ON" ? "true" : "false"; } elsif($_ =~ /^ SHARED: \'(.*)\'/) { - $job{'shared'} = $1 eq "ON" ? "true": "false"; + $job{'shared'} = $1 eq "ON" ? "true" : "false"; } elsif($_ =~ /^ TARGET: \'-A (.*)\'/) { $job{'target'} = $1; @@ -464,7 +464,7 @@ sub zuul { $var = "compiler"; } elsif($var eq "CHECKSRC") { - $job{'checksrc'} = $value ? "true": "false"; + $job{'checksrc'} = $value ? "true" : "false"; $var = ""; } else { diff --git a/scripts/managen b/scripts/managen index 7c4adac730..f800f37dd9 100755 --- a/scripts/managen +++ b/scripts/managen @@ -116,7 +116,7 @@ sub justline { print " "; $spare--; } - printf "%s%s", $prev?" ":"", $_; + printf "%s%s", $prev ? " " : "", $_; $prev = 1; $spare += $ratio; } @@ -131,7 +131,7 @@ sub lastline { prefixline($lvl * $indent + $l); my $prev = 0; for(@line) { - printf "%s%s", $prev?" ":"", $_; + printf "%s%s", $prev ? " " : "", $_; $prev = 1; } print "\n"; @@ -526,7 +526,7 @@ sub render { push @desc, "\n" if($blankline && !$header); $blankline = 0; push @desc, $d if($manpage); - my $qstr = $quote ? "q": ""; + my $qstr = $quote ? "q" : ""; push @desc, "[".(1 + $level)."$qstr]$d" if(!$manpage); $header = 0; @@ -760,7 +760,7 @@ sub single { push @leading, "$pref**WARNING**: this option is experimental. Do not use in production.\n\n"; } - my $pre = $manpage ? "\n": "[1]"; + my $pre = $manpage ? "\n" : "[1]"; if($scope) { if($category !~ /global/) { @@ -846,7 +846,7 @@ sub single { if($and && ($i < $and)) { $sep = ","; } - $mstr .= sprintf "%s$l", $mstr?"$sep ":""; + $mstr .= sprintf "%s$l", $mstr ? "$sep " : ""; $i++; } diff --git a/scripts/mk-ca-bundle.pl b/scripts/mk-ca-bundle.pl index 0f32cec7cf..79a5a90d32 100755 --- a/scripts/mk-ca-bundle.pl +++ b/scripts/mk-ca-bundle.pl @@ -166,7 +166,7 @@ sub HELP_MESSAGE() { print "\t-b\tbackup an existing version of ca-bundle.crt\n"; print "\t-d\tspecify Mozilla tree to pull certdata.txt or custom URL\n"; print "\t\t Valid names are:\n"; - print "\t\t ", join( ", ", map { ( $_ =~ m/$opt_d/ ) ? "$_ (default)" : "$_" } sort keys %urls ), "\n"; + print "\t\t ", join(", ", map { ($_ =~ m/$opt_d/) ? "$_ (default)" : "$_" } sort keys %urls), "\n"; print "\t-f\tforce rebuild even if certdata.txt is current\n"; print "\t-i\tprint version info about used modules\n"; print "\t-k\tallow URLs other than HTTPS, enable HTTP fallback (insecure)\n"; @@ -175,13 +175,13 @@ sub HELP_MESSAGE() { print "\t-n\tno download of certdata.txt (to use existing)\n"; print wrap("\t","\t\t", "-p\tlist of Mozilla trust purposes and levels for certificates to include in output. Takes the form of a comma separated list of purposes, a colon, and a comma separated list of levels. (default: $default_mozilla_trust_purposes:$default_mozilla_trust_levels)"), "\n"; print "\t\t Valid purposes are:\n"; - print wrap("\t\t ","\t\t ", join( ", ", "ALL", @valid_mozilla_trust_purposes ) ), "\n"; + print wrap("\t\t ","\t\t ", join(", ", "ALL", @valid_mozilla_trust_purposes)), "\n"; print "\t\t Valid levels are:\n"; - print wrap("\t\t ","\t\t ", join( ", ", "ALL", @valid_mozilla_trust_levels ) ), "\n"; + print wrap("\t\t ","\t\t ", join(", ", "ALL", @valid_mozilla_trust_levels)), "\n"; print "\t-q\tbe really quiet (no progress output at all)\n"; print wrap("\t","\t\t", "-s\tcomma separated list of certificate signatures/hashes to output in plain text mode. (default: $default_signature_algorithms)\n"); print "\t\t Valid signature algorithms are:\n"; - print wrap("\t\t ","\t\t ", join( ", ", "ALL", @valid_signature_algorithms ) ), "\n"; + print wrap("\t\t ","\t\t ", join(", ", "ALL", @valid_signature_algorithms)), "\n"; print "\t-t\tinclude plain text listing of certificates\n"; print "\t-u\tunlink (remove) certdata.txt after processing\n"; print "\t-v\tbe verbose and print out processed CAs\n"; @@ -193,7 +193,7 @@ sub VERSION_MESSAGE() { print "${0} version ${version} running Perl ${]} on ${^O}\n"; } -warning_message() unless ($opt_q || $url =~ m/^(ht|f)tps:/i ); +warning_message() unless ($opt_q || $url =~ m/^(ht|f)tps:/i); HELP_MESSAGE() if($opt_h); sub report($@) { @@ -219,7 +219,7 @@ sub parse_csv_param($$@) { s/^\s+//; # strip leading spaces s/\s+$//; # strip trailing spaces uc $_ # return the modified string as upper case - } split( ',', $param_string ); + } split(',', $param_string); # Find all values which are not in the list of valid values or "ALL" my @invalid = grep { !is_in_list($_,"ALL",@valid_values) } @values; @@ -227,7 +227,7 @@ sub parse_csv_param($$@) { if(scalar(@invalid) > 0) { # Tell the user which parameters were invalid and print the standard help # message which will exit - print "Error: Invalid ", $description, scalar(@invalid) == 1 ? ": " : "s: ", join( ", ", map { "\"$_\"" } @invalid ), "\n"; + print "Error: Invalid ", $description, scalar(@invalid) == 1 ? ": " : "s: ", join(", ", map { "\"$_\"" } @invalid), "\n"; HELP_MESSAGE(); } @@ -272,11 +272,11 @@ if($opt_p !~ m/:/) { HELP_MESSAGE(); } -(my $included_mozilla_trust_purposes_string, my $included_mozilla_trust_levels_string) = split( ':', $opt_p ); -my @included_mozilla_trust_purposes = parse_csv_param( "trust purpose", $included_mozilla_trust_purposes_string, @valid_mozilla_trust_purposes ); -my @included_mozilla_trust_levels = parse_csv_param( "trust level", $included_mozilla_trust_levels_string, @valid_mozilla_trust_levels ); +(my $included_mozilla_trust_purposes_string, my $included_mozilla_trust_levels_string) = split(':', $opt_p); +my @included_mozilla_trust_purposes = parse_csv_param("trust purpose", $included_mozilla_trust_purposes_string, @valid_mozilla_trust_purposes); +my @included_mozilla_trust_levels = parse_csv_param("trust level", $included_mozilla_trust_levels_string, @valid_mozilla_trust_levels); -my @included_signature_algorithms = parse_csv_param( "signature algorithm", $opt_s, @valid_signature_algorithms ); +my @included_signature_algorithms = parse_csv_param("signature algorithm", $opt_s, @valid_signature_algorithms); sub should_output_cert(%) { my %trust_purposes_by_level = @_; @@ -284,7 +284,7 @@ sub should_output_cert(%) { foreach my $level (@included_mozilla_trust_levels) { # for each level we want to output, see if any of our desired purposes are # included - return 1 if(defined( List::Util::first { is_in_list( $_, @included_mozilla_trust_purposes ) } @{$trust_purposes_by_level{$level}} )); + return 1 if(defined(List::Util::first { is_in_list($_, @included_mozilla_trust_purposes) } @{$trust_purposes_by_level{$level}})); } return 0; @@ -378,7 +378,7 @@ my $datesrc = "as of"; if(!$filedate) { # mxr.mozilla.org gave us a time, hg.mozilla.org does not! $filedate = time(); - $datesrc="downloaded on"; + $datesrc = "downloaded on"; } # get the hash from the download file diff --git a/scripts/top-complexity b/scripts/top-complexity index 6cfd58c73f..7ee0c825ec 100755 --- a/scripts/top-complexity +++ b/scripts/top-complexity @@ -121,7 +121,7 @@ for my $e (sort {$where{$b} <=> $where{$a}} keys %where) { $showncutoff = 1; } printf "%-5d %s%s\n", $where{$e}, $e, - $perm{$e} ? " [ALLOWED]": ""; + $perm{$e} ? " [ALLOWED]" : ""; if(!--$top) { last; } diff --git a/src/mkhelp.pl b/src/mkhelp.pl index b3a6c5abdc..053f741776 100755 --- a/src/mkhelp.pl +++ b/src/mkhelp.pl @@ -153,6 +153,7 @@ void hugehelp(void) } inflateEnd(&z); } + /* Show the help text for the 'arg' curl argument on stdout */ void showhelp(const char *trigger, const char *arg, const char *endarg) { @@ -219,7 +220,7 @@ for my $n (@out) { } else { $n =~ s/ /\\t/g; - printf(" \"%s%s\",\n", $blank?"\\n":"", $n); + printf(" \"%s%s\",\n", $blank ? "\\n" : "", $n); $blank = 0; } } diff --git a/src/tool_cb_rea.c b/src/tool_cb_rea.c index 2343d04a13..8edd121f12 100644 --- a/src/tool_cb_rea.c +++ b/src/tool_cb_rea.c @@ -57,8 +57,7 @@ static bool waitfd(int waitms, int fd) struct timeval timeout; if(fd >= FD_SETSIZE) - /* cannot wait! */ - return FALSE; + return FALSE; /* cannot wait! */ /* wait this long at the most */ timeout.tv_sec = waitms / 1000; @@ -94,8 +93,7 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata) long msdelta = (long)curlx_timediff_ms(now, per->start); if(msdelta > config->timeout_ms) - /* timeout */ - return 0; + return 0; /* timeout */ #ifndef _WIN32 else { long w = config->timeout_ms - msdelta; @@ -181,8 +179,7 @@ int tool_readbusy_cb(void *clientp, #ifndef _WIN32 waitfd(1, per->infd); #else - /* sleep */ - curlx_wait_ms(1); + curlx_wait_ms(1); /* sleep */ #endif } diff --git a/src/tool_doswin.c b/src/tool_doswin.c index 193446cba3..ad290f377a 100644 --- a/src/tool_doswin.c +++ b/src/tool_doswin.c @@ -67,30 +67,30 @@ char **__crt0_glob_function(char *arg) #endif /* -Test if truncating a path to a file will leave at least a single character in -the filename. Filenames suffixed by an alternate data stream cannot be -truncated. This performs a dry run, nothing is modified. - -Good truncate_pos 9: C:\foo\bar => C:\foo\ba -Good truncate_pos 6: C:\foo => C:\foo -Good truncate_pos 5: C:\foo => C:\fo -Bad* truncate_pos 5: C:foo => C:foo -Bad truncate_pos 5: C:\foo:ads => C:\fo -Bad truncate_pos 9: C:\foo:ads => C:\foo:ad -Bad truncate_pos 5: C:\foo\bar => C:\fo -Bad truncate_pos 5: C:\foo\ => C:\fo -Bad truncate_pos 7: C:\foo\ => C:\foo\ -Error truncate_pos 7: C:\foo => (pos out of range) -Bad truncate_pos 1: C:\foo\ => C - -* C:foo is ambiguous, C could end up being a drive or file therefore something - like C:superlongfilename cannot be truncated. - -Returns -SANITIZE_ERR_OK: Good -- 'path' can be truncated -SANITIZE_ERR_INVALID_PATH: Bad -- 'path' cannot be truncated -!= SANITIZE_ERR_OK && != SANITIZE_ERR_INVALID_PATH: Error -*/ + * Test if truncating a path to a file will leave at least a single character + * in the filename. Filenames suffixed by an alternate data stream cannot be + * truncated. This performs a dry run, nothing is modified. + * + * Good truncate_pos 9: C:\foo\bar => C:\foo\ba + * Good truncate_pos 6: C:\foo => C:\foo + * Good truncate_pos 5: C:\foo => C:\fo + * Bad* truncate_pos 5: C:foo => C:foo + * Bad truncate_pos 5: C:\foo:ads => C:\fo + * Bad truncate_pos 9: C:\foo:ads => C:\foo:ad + * Bad truncate_pos 5: C:\foo\bar => C:\fo + * Bad truncate_pos 5: C:\foo\ => C:\fo + * Bad truncate_pos 7: C:\foo\ => C:\foo\ + * Error truncate_pos 7: C:\foo => (pos out of range) + * Bad truncate_pos 1: C:\foo\ => C + * + * * C:foo is ambiguous, C could end up being a drive or file therefore + * something like C:superlongfilename cannot be truncated. + * + * Returns + * SANITIZE_ERR_OK: Good -- 'path' can be truncated + * SANITIZE_ERR_INVALID_PATH: Bad -- 'path' cannot be truncated + * != SANITIZE_ERR_OK && != SANITIZE_ERR_INVALID_PATH: Error + */ static SANITIZEcode truncate_dryrun(const char *path, const size_t truncate_pos) { @@ -124,18 +124,18 @@ static SANITIZEcode truncate_dryrun(const char *path, } /* -Extra sanitization MS-DOS for file_name. - -This is a supporting function for sanitize_file_name. - -Warning: This is an MS-DOS legacy function and was purposely written in a way -that some path information may pass through. For example drive letter names -(C:, D:, etc) are allowed to pass through. For sanitizing a filename use -sanitize_file_name. - -Success: (SANITIZE_ERR_OK) *sanitized points to a sanitized copy of file_name. -Failure: (!= SANITIZE_ERR_OK) *sanitized is NULL. -*/ + * Extra sanitization MS-DOS for file_name. + * + * This is a supporting function for sanitize_file_name. + * + * Warning: This is an MS-DOS legacy function and was purposely written in + * a way that some path information may pass through. For example drive letter + * names (C:, D:, etc) are allowed to pass through. For sanitizing a filename + * use sanitize_file_name. + * + * Success: SANITIZE_ERR_OK *sanitized points to a sanitized copy of file_name. + * Failure: != SANITIZE_ERR_OK *sanitized is NULL. + */ static SANITIZEcode msdosify(char ** const sanitized, const char *file_name, int flags) { @@ -171,7 +171,7 @@ static SANITIZEcode msdosify(char ** const sanitized, const char *file_name, /* Get past the drive letter, if any. */ if(s[0] >= 'A' && s[0] <= 'z' && s[1] == ':') { *d++ = *s++; - *d = ((flags & SANITIZE_ALLOW_PATH)) ? ':' : '_'; + *d = (flags & SANITIZE_ALLOW_PATH) ? ':' : '_'; ++d; ++s; } @@ -270,25 +270,25 @@ static SANITIZEcode msdosify(char ** const sanitized, const char *file_name, #endif /* MSDOS */ /* -Rename file_name if it is a reserved dos device name. - -This is a supporting function for sanitize_file_name. - -Warning: This is an MS-DOS legacy function and was purposely written in a way -that some path information may pass through. For example drive letter names -(C:, D:, etc) are allowed to pass through. For sanitizing a filename use -sanitize_file_name. - -Success: (SANITIZE_ERR_OK) *sanitized points to a sanitized copy of file_name. -Failure: (!= SANITIZE_ERR_OK) *sanitized is NULL. -*/ + * Rename file_name if it is a reserved dos device name. + * + * This is a supporting function for sanitize_file_name. + * + * Warning: This is an MS-DOS legacy function and was purposely written in + * a way that some path information may pass through. For example drive letter + * names (C:, D:, etc) are allowed to pass through. For sanitizing a filename + * use sanitize_file_name. + * + * Success: SANITIZE_ERR_OK *sanitized points to a sanitized copy of file_name. + * Failure: != SANITIZE_ERR_OK *sanitized is NULL. + */ static SANITIZEcode rename_if_reserved_dos(char ** const sanitized, const char *file_name, int flags) { /* We could have a file whose name is a device on MS-DOS. Trying to - * retrieve such a file would fail at best and wedge us at worst. We need - * to rename such files. */ + retrieve such a file would fail at best and wedge us at worst. We need + to rename such files. */ char *p, *base, *buffer; #ifdef MSDOS curlx_struct_stat st_buf; @@ -404,33 +404,34 @@ static SANITIZEcode rename_if_reserved_dos(char ** const sanitized, } /* -Sanitize a file or path name. - -All banned characters are replaced by underscores, for example: -f?*foo => f__foo -f:foo::$DATA => f_foo__$DATA -f:\foo:bar => f__foo_bar -f:\foo:bar => f:\foo:bar (flag SANITIZE_ALLOW_PATH) - -This function was implemented according to the guidelines in 'Naming Files, -Paths, and Namespaces' section 'Naming Conventions'. -https://learn.microsoft.com/windows/win32/fileio/naming-a-file - -Flags ------ -SANITIZE_ALLOW_PATH: Allow path separators and colons. -Without this flag path separators and colons are sanitized. - -SANITIZE_ALLOW_RESERVED: Allow reserved device names. -Without this flag a reserved device name is renamed (COM1 => _COM1). - -To fully block reserved device names requires not passing either flag. Some -less common path styles are allowed to use reserved device names. For example, -a "\\" prefixed path may use reserved device names if paths are allowed. - -Success: (SANITIZE_ERR_OK) *sanitized points to a sanitized copy of file_name. -Failure: (!= SANITIZE_ERR_OK) *sanitized is NULL. -*/ + * Sanitize a file or path name. + * + * All banned characters are replaced by underscores, for example: + * f?*foo => f__foo + * f:foo::$DATA => f_foo__$DATA + * f:\foo:bar => f__foo_bar + * f:\foo:bar => f:\foo:bar (flag SANITIZE_ALLOW_PATH) + * + * This function was implemented according to the guidelines in 'Naming Files, + * Paths, and Namespaces' section 'Naming Conventions'. + * https://learn.microsoft.com/windows/win32/fileio/naming-a-file + * + * Flags + * ----- + * SANITIZE_ALLOW_PATH: Allow path separators and colons. + * Without this flag path separators and colons are sanitized. + * + * SANITIZE_ALLOW_RESERVED: Allow reserved device names. + * Without this flag a reserved device name is renamed (COM1 => _COM1). + * + * To fully block reserved device names requires not passing either flag. + * Some less common path styles are allowed to use reserved device names. + * For example, a "\\" prefixed path may use reserved device names if paths + * are allowed. + * + * Success: SANITIZE_ERR_OK *sanitized points to a sanitized copy of file_name. + * Failure: != SANITIZE_ERR_OK *sanitized is NULL. + */ SANITIZEcode sanitize_file_name(char ** const sanitized, const char *file_name, int flags) { @@ -708,11 +709,6 @@ struct win_thread_data { static DWORD WINAPI win_stdin_thread_func(void *thread_data) { struct win_thread_data *tdata = (struct win_thread_data *)thread_data; - DWORD n; - ssize_t nwritten; - char buffer[BUFSIZ]; - BOOL r; - struct sockaddr_in clientAddr; int clientAddrLen = sizeof(clientAddr); @@ -732,8 +728,11 @@ static DWORD WINAPI win_stdin_thread_func(void *thread_data) goto ThreadCleanup; } for(;;) { - r = ReadFile(tdata->stdin_handle, buffer, sizeof(buffer), &n, NULL); - if(r == 0) + DWORD n; + ssize_t nwritten; + char buffer[BUFSIZ]; + + if(!ReadFile(tdata->stdin_handle, buffer, sizeof(buffer), &n, NULL)) break; if(n == 0) break; @@ -760,11 +759,8 @@ ThreadCleanup: /* The background thread that reads and buffers the true stdin. */ curl_socket_t win32_stdin_read_thread(void) { - bool r; int rc = 0; - curl_socklen_t socksize = 0; struct win_thread_data *tdata = NULL; - struct sockaddr_in selfaddr; static HANDLE stdin_thread = NULL; static curl_socket_t socket_r = CURL_SOCKET_BAD; @@ -775,6 +771,9 @@ curl_socket_t win32_stdin_read_thread(void) assert(stdin_thread == NULL); do { + curl_socklen_t socksize = 0; + struct sockaddr_in selfaddr; + /* Prepare handles for thread */ tdata = (struct win_thread_data *) curlx_calloc(1, sizeof(struct win_thread_data)); @@ -812,11 +811,9 @@ curl_socket_t win32_stdin_read_thread(void) } /* Make a copy of the stdin handle to be used by win_stdin_thread_func */ - r = DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_INPUT_HANDLE), + if(!DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_INPUT_HANDLE), GetCurrentProcess(), &tdata->stdin_handle, - 0, FALSE, DUPLICATE_SAME_ACCESS); - - if(!r) { + 0, FALSE, DUPLICATE_SAME_ACCESS)) { errorf("DuplicateHandle error: 0x%08lx", GetLastError()); break; } diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 86ebed13e8..42c7207242 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -3130,7 +3130,8 @@ ParameterError parse_args(int argc, argv_item_t argv[]) err = PARAM_CONTDISP_RESUME_FROM; } - if(err && err != PARAM_HELP_REQUESTED && + if(err && + err != PARAM_HELP_REQUESTED && err != PARAM_MANUAL_REQUESTED && err != PARAM_VERSION_INFO_REQUESTED && err != PARAM_ENGINES_REQUESTED && diff --git a/src/tool_setopt.c b/src/tool_setopt.c index 2ffcd1076b..003b772328 100644 --- a/src/tool_setopt.c +++ b/src/tool_setopt.c @@ -465,10 +465,10 @@ static CURLcode libcurl_generate_mime_part(CURL *curl, case TOOLMIME_STDINDATA: /* Can only be reading stdin in the current context. */ result = easysrc_addf(&easysrc_code, "curl_mime_data_cb(part%d, -1, " - "(curl_read_callback) fread, \\", mimeno); + "(curl_read_callback)fread, \\", mimeno); if(!result) result = easysrc_addf(&easysrc_code, " " - "(curl_seek_callback) fseek, NULL, stdin);"); + "(curl_seek_callback)fseek, NULL, stdin);"); break; default: /* Other cases not possible in this context. */ diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index e33f87c993..dfe1aaaa54 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -2587,7 +2587,7 @@ sub PASV_ftp { local $SIG{ALRM} = sub { die "alarm\n" }; # assume swift operations unless explicitly slow - alarm ($datadelay?20:2); + alarm ($datadelay ? 20 : 2); # Wait for 'CNCT' my $input; diff --git a/tests/libtest/first.h b/tests/libtest/first.h index 1c8217ed82..425566ba14 100644 --- a/tests/libtest/first.h +++ b/tests/libtest/first.h @@ -87,16 +87,15 @@ extern char *hexdump(const unsigned char *buffer, size_t len); #ifndef CURL_DISABLE_WEBSOCKETS CURLcode ws_send_ping(CURL *curl, const char *send_payload); CURLcode ws_recv_pong(CURL *curl, const char *expected_payload); -/* just close the connection */ -void ws_close(CURL *curl); +void ws_close(CURL *curl); /* just close the connection */ #endif /* -** TEST_ERR_* values must within the CURLcode range to not cause compiler -** errors. - -** For portability reasons TEST_ERR_* values should be less than 127. -*/ + * TEST_ERR_* values must within the CURLcode range to not cause compiler + * errors. + * + * For portability reasons TEST_ERR_* values should be less than 127. + */ #define TEST_ERR_MAJOR_BAD CURLE_OBSOLETE20 #define TEST_ERR_RUNS_FOREVER CURLE_OBSOLETE24 @@ -112,33 +111,33 @@ void ws_close(CURL *curl); #define TEST_ERR_BAD_TIMEOUT CURLE_OBSOLETE57 /* -** Macros for test source code readability/maintainability. -** -** All of the following macros require that an int data type 'res' variable -** exists in scope where macro is used, and that it has been initialized to -** zero before the macro is used. -** -** exe_* and chk_* macros are helper macros not intended to be used from -** outside of this header file. Arguments 'Y' and 'Z' of these represent -** source code file and line number, while Arguments 'A', 'B', etc, are -** the arguments used to actually call a libcurl function. -** -** All easy_* and multi_* macros call a libcurl function and evaluate if -** the function has succeeded or failed. When the function succeeds 'res' -** variable is not set nor cleared and program continues normal flow. On -** the other hand if function fails 'res' variable is set and a jump to -** label 'test_cleanup' is performed. -** -** Every easy_* and multi_* macros have a res_easy_* and res_multi_* macro -** counterpart that operates in the same way with the exception that no -** jump takes place in case of failure. res_easy_* and res_multi_* macros -** should be immediately followed by checking if 'res' variable has been -** set. -** -** 'res' variable when set will hold a CURLcode, CURLMcode, or any of the -** TEST_ERR_* values defined above. It is advisable to return this value -** as test result. -*/ + * Macros for test source code readability/maintainability. + * + * All of the following macros require that an int data type 'res' variable + * exists in scope where macro is used, and that it has been initialized to + * zero before the macro is used. + * + * exe_* and chk_* macros are helper macros not intended to be used from + * outside of this header file. Arguments 'Y' and 'Z' of these represent + * source code file and line number, while Arguments 'A', 'B', etc, are + * the arguments used to actually call a libcurl function. + * + * All easy_* and multi_* macros call a libcurl function and evaluate if + * the function has succeeded or failed. When the function succeeds 'res' + * variable is not set nor cleared and program continues normal flow. On + * the other hand if function fails 'res' variable is set and a jump to + * label 'test_cleanup' is performed. + * + * Every easy_* and multi_* macros have a res_easy_* and res_multi_* macro + * counterpart that operates in the same way with the exception that no + * jump takes place in case of failure. res_easy_* and res_multi_* macros + * should be immediately followed by checking if 'res' variable has been + * set. + * + * 'res' variable when set will hold a CURLcode, CURLMcode, or any of the + * TEST_ERR_* values defined above. It is advisable to return this value + * as test result. + */ /* ---------------------------------------------------------------- */ @@ -156,7 +155,7 @@ void ws_close(CURL *curl); #define chk_easy_init(A, Y, Z) \ do { \ exe_easy_init(A, Y, Z); \ - if(result) \ + if(result) \ goto test_cleanup; \ } while(0) @@ -296,23 +295,23 @@ void ws_close(CURL *curl); /* ---------------------------------------------------------------- */ -#define exe_multi_perform(A, B, Y, Z) \ - do { \ - CURLMcode ec; \ - if((ec = curl_multi_perform(A, B)) != CURLM_OK) { \ - curl_mfprintf(stderr, \ - "%s:%d curl_multi_perform() failed, " \ - "with code %d (%s)\n", \ - Y, Z, ec, curl_multi_strerror(ec)); \ - result = TEST_ERR_MULTI; \ - } \ - else if(*(B) < 0) { \ - curl_mfprintf(stderr, \ - "%s:%d curl_multi_perform() succeeded, " \ +#define exe_multi_perform(A, B, Y, Z) \ + do { \ + CURLMcode ec; \ + if((ec = curl_multi_perform(A, B)) != CURLM_OK) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_perform() failed, " \ + "with code %d (%s)\n", \ + Y, Z, ec, curl_multi_strerror(ec)); \ + result = TEST_ERR_MULTI; \ + } \ + else if(*(B) < 0) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_perform() succeeded, " \ "but returned invalid running_handles value (%d)\n", \ - Y, Z, (int)*(B)); \ - result = TEST_ERR_NUM_HANDLES; \ - } \ + Y, Z, (int)*(B)); \ + result = TEST_ERR_NUM_HANDLES; \ + } \ } while(0) #define res_multi_perform(A, B) \ @@ -450,7 +449,7 @@ void ws_close(CURL *curl); #define chk_multi_wakeup(A, Y, Z) \ do { \ exe_multi_wakeup(A, Y, Z); \ - if(result) \ + if(result) \ goto test_cleanup; \ } while(0) diff --git a/tests/libtest/lib1560.c b/tests/libtest/lib1560.c index 1b329f7cfd..29912a221b 100644 --- a/tests/libtest/lib1560.c +++ b/tests/libtest/lib1560.c @@ -50,16 +50,16 @@ static int checkparts(CURLU *u, const char *in, const char *wanted, }; struct part parts[] = { - {CURLUPART_SCHEME, "scheme"}, - {CURLUPART_USER, "user"}, - {CURLUPART_PASSWORD, "password"}, - {CURLUPART_OPTIONS, "options"}, - {CURLUPART_HOST, "host"}, - {CURLUPART_PORT, "port"}, - {CURLUPART_PATH, "path"}, - {CURLUPART_QUERY, "query"}, - {CURLUPART_FRAGMENT, "fragment"}, - {CURLUPART_URL, NULL} + { CURLUPART_SCHEME, "scheme" }, + { CURLUPART_USER, "user" }, + { CURLUPART_PASSWORD, "password" }, + { CURLUPART_OPTIONS, "options" }, + { CURLUPART_HOST, "host" }, + { CURLUPART_PORT, "port" }, + { CURLUPART_PATH, "path" }, + { CURLUPART_QUERY, "query" }, + { CURLUPART_FRAGMENT, "fragment" }, + { CURLUPART_URL, NULL } }; memset(buf, 0, sizeof(buf)); diff --git a/tests/libtest/lib678.c b/tests/libtest/lib678.c index 3acfabc90b..73aa4ee7e9 100644 --- a/tests/libtest/lib678.c +++ b/tests/libtest/lib678.c @@ -43,7 +43,7 @@ static int loadfile(const char *filename, void **filedata, size_t *filesize) continue_reading = fseek(fInCert, 0, SEEK_SET) == 0; if(continue_reading) data = curlx_malloc(datasize + 1); - if((!data) || ((int)fread(data, datasize, 1, fInCert) != 1)) + if(!data || ((int)fread(data, datasize, 1, fInCert) != 1)) continue_reading = FALSE; curlx_fclose(fInCert); if(!continue_reading) { diff --git a/tests/runner.pm b/tests/runner.pm index 8589f74640..94ddc77a8f 100644 --- a/tests/runner.pm +++ b/tests/runner.pm @@ -666,7 +666,7 @@ sub singletest_setenv { if($s =~ /([^=]*)(.*)/) { my ($var, $content) = ($1, $2); # remember current setting, to restore it once test runs - $oldenv{$var} = ($ENV{$var})?"$ENV{$var}":'notset'; + $oldenv{$var} = ($ENV{$var}) ? "$ENV{$var}" : 'notset'; if($content =~ /^=(.*)/) { # assign it diff --git a/tests/runtests.pl b/tests/runtests.pl index 010acb086e..e0bc468f10 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -765,7 +765,7 @@ sub checksystemfeatures { } elsif($versretval & 127) { logmsg sprintf("command died with signal %d, and %s coredump.\n", - ($versretval & 127), ($versretval & 128)?"a":"no"); + ($versretval & 127), ($versretval & 128) ? "a" : "no"); } else { logmsg sprintf("command exited with value %d \n", $versretval >> 8); @@ -873,11 +873,11 @@ sub checksystemfeatures { } my $env = sprintf("%s%s%s%s%s", - $valgrind?"Valgrind ":"", - $run_duphandle?"test-duphandle ":"", - $run_event_based?"event-based ":"", - $nghttpx_h3?"nghttpx-h3 " :"", - $libtool?"Libtool ":""); + $valgrind ? "Valgrind " : "", + $run_duphandle ? "test-duphandle " : "", + $run_event_based ? "event-based " : "", + $nghttpx_h3 ? "nghttpx-h3 " : "", + $libtool ? "Libtool " : ""); if($env) { logmsg "* Env: $env\n"; } @@ -894,10 +894,10 @@ sub checksystemfeatures { # display information about server features # sub displayserverfeatures { - logmsg sprintf("* Servers: %s", $stunnel?"SSL ":""); - logmsg sprintf("%s", $http_ipv6?"HTTP-IPv6 ":""); - logmsg sprintf("%s", $http_unix?"HTTP-unix ":""); - logmsg sprintf("%s\n", $ftp_ipv6?"FTP-IPv6 ":""); + logmsg sprintf("* Servers: %s", $stunnel ? "SSL " : ""); + logmsg sprintf("%s", $http_ipv6 ? "HTTP-IPv6 " : ""); + logmsg sprintf("%s", $http_unix ? "HTTP-unix " : ""); + logmsg sprintf("%s\n", $ftp_ipv6 ? "FTP-IPv6 " : ""); logmsg "***************************************** \n"; } @@ -1732,7 +1732,7 @@ sub singletest_check { else { if(!$short) { logmsg sprintf("\n%s returned $cmdres, when expecting %s\n", - (!$tool)?"curl":$tool, $errorcode); + (!$tool) ? "curl" : $tool, $errorcode); } logmsg " $testnum: exit FAILED\n"; # timestamp test result verification end @@ -2192,7 +2192,7 @@ sub runtimestats { $counter = 25; logmsg "\nTest server starting and verification time per test ". - sprintf("(%s)...\n\n", (not $fullstats)?"top $counter":"full"); + sprintf("(%s)...\n\n", (not $fullstats) ? "top $counter" : "full"); logmsg "-time- test\n"; logmsg "------ ----\n"; foreach my $txt (@timesrvr) { @@ -2202,7 +2202,7 @@ sub runtimestats { $counter = 10; logmsg "\nTest definition reading and preparation time per test ". - sprintf("(%s)...\n\n", (not $fullstats)?"top $counter":"full"); + sprintf("(%s)...\n\n", (not $fullstats) ? "top $counter" : "full"); logmsg "-time- test\n"; logmsg "------ ----\n"; foreach my $txt (@timeprep) { @@ -2212,7 +2212,7 @@ sub runtimestats { $counter = 25; logmsg "\nTest tool execution time per test ". - sprintf("(%s)...\n\n", (not $fullstats)?"top $counter":"full"); + sprintf("(%s)...\n\n", (not $fullstats) ? "top $counter" : "full"); logmsg "-time- test\n"; logmsg "------ ----\n"; foreach my $txt (@timetool) { @@ -2222,7 +2222,7 @@ sub runtimestats { $counter = 15; logmsg "\nTest server logs lock removal time per test ". - sprintf("(%s)...\n\n", (not $fullstats)?"top $counter":"full"); + sprintf("(%s)...\n\n", (not $fullstats) ? "top $counter" : "full"); logmsg "-time- test\n"; logmsg "------ ----\n"; foreach my $txt (@timelock) { @@ -2232,7 +2232,7 @@ sub runtimestats { $counter = 10; logmsg "\nTest results verification time per test ". - sprintf("(%s)...\n\n", (not $fullstats)?"top $counter":"full"); + sprintf("(%s)...\n\n", (not $fullstats) ? "top $counter" : "full"); logmsg "-time- test\n"; logmsg "------ ----\n"; foreach my $txt (@timevrfy) { @@ -2242,7 +2242,7 @@ sub runtimestats { $counter = 50; logmsg "\nTotal time per test ". - sprintf("(%s)...\n\n", (not $fullstats)?"top $counter":"full"); + sprintf("(%s)...\n\n", (not $fullstats) ? "top $counter" : "full"); logmsg "-time- test\n"; logmsg "------ ----\n"; foreach my $txt (@timetest) { diff --git a/tests/secureserver.pl b/tests/secureserver.pl index 8471e144e7..e771cc7d0f 100755 --- a/tests/secureserver.pl +++ b/tests/secureserver.pl @@ -205,7 +205,7 @@ $certfile = abs_path($certfile); my $ssltext = uc($proto) ." SSL/TLS:"; -my $host_ip = ($ipvnum == 6)? '::1' : '127.0.0.1'; +my $host_ip = ($ipvnum == 6) ? '::1' : '127.0.0.1'; #*************************************************************************** # Find out version info for the given stunnel binary diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c index 2af3f6601f..f9a5f7a84f 100644 --- a/tests/server/rtspd.c +++ b/tests/server/rtspd.c @@ -1250,7 +1250,7 @@ static int test_rtspd(int argc, const char *argv[]) */ flag = 1; if(setsockopt(msgsock, IPPROTO_TCP, TCP_NODELAY, - (void *)&flag, sizeof(flag)) == -1) { + (void *)&flag, sizeof(flag)) == -1) { logmsg("====> TCP_NODELAY failed"); } #endif diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index 9bb6c41847..6bdd5633b1 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -597,12 +597,10 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, { DWORD timeout_ms, wait, nfd, nth, nws, i; HANDLE abort, signal, handle, *handles; - fd_set readsock, writesock, exceptsock; struct select_ws_data *data; WSANETWORKEVENTS wsaevents; curl_socket_t wsasock; - int error, ret, fd; - WSAEVENT wsaevent; + int ret, fd; /* check if the input value is valid */ if(nfds < 0) { @@ -653,6 +651,8 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, nth = 0; /* number of internal waiting threads */ nws = 0; /* number of handled Winsock sockets */ for(fd = 0; fd < nfds; fd++) { + fd_set readsock, writesock, exceptsock; + wsasock = (curl_socket_t)fd; wsaevents.lNetworkEvents = 0; handles[nfd] = 0; @@ -705,13 +705,14 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, nfd++; } else { + WSAEVENT wsaevent; wsaevent = WSACreateEvent(); if(wsaevent != WSA_INVALID_EVENT) { if(wsaevents.lNetworkEvents & FD_WRITE) { swrite(wsasock, NULL, 0); /* reset FD_WRITE */ } - error = WSAEventSelect(wsasock, wsaevent, wsaevents.lNetworkEvents); - if(error != SOCKET_ERROR) { + if(WSAEventSelect(wsasock, wsaevent, wsaevents.lNetworkEvents) + == 0) { handles[nfd] = (HANDLE)wsaevent; data[nws].wsasock = wsasock; data[nws].wsaevent = wsaevent; @@ -799,8 +800,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, else { /* try to handle the event with the Winsock2 functions */ wsaevents.lNetworkEvents = 0; - error = WSAEnumNetworkEvents(wsasock, handle, &wsaevents); - if(error != SOCKET_ERROR) { + if(WSAEnumNetworkEvents(wsasock, handle, &wsaevents) == 0) { /* merge result from pre-check using select */ wsaevents.lNetworkEvents |= data[i].wsastate; @@ -1010,16 +1010,13 @@ static bool juggle(curl_socket_t *sockfdp, } /* switch(*mode) */ do { - /* select() blocking behavior call on blocking descriptors please */ - rc = SOCKFILT_select(maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout); if(got_exit_signal) { logmsg("signalled to die, exiting..."); return FALSE; } - } while((rc == -1) && ((error = SOCKERRNO) == SOCKEINTR)); if(rc < 0) { diff --git a/tests/serverhelp.pm b/tests/serverhelp.pm index eaf5b42804..272e0386cf 100644 --- a/tests/serverhelp.pm +++ b/tests/serverhelp.pm @@ -247,7 +247,7 @@ sub mainsockf_pidfilename { my ($piddir, $proto, $ipver, $idnum) = @_; die "unsupported protocol: '$proto'" unless($proto && (lc($proto) =~ /^(ftp|imap|pop3|smtp)s?$/)); - my $trailer = (lc($proto) =~ /^ftps?$/) ? '_sockctrl.pid':'_sockfilt.pid'; + my $trailer = (lc($proto) =~ /^ftps?$/) ? '_sockctrl.pid' : '_sockfilt.pid'; return "${piddir}/". servername_canon($proto, $ipver, $idnum) ."$trailer"; } @@ -258,7 +258,7 @@ sub mainsockf_logfilename { my ($logdir, $proto, $ipver, $idnum) = @_; die "unsupported protocol: '$proto'" unless($proto && (lc($proto) =~ /^(ftp|imap|pop3|smtp)s?$/)); - my $trailer = (lc($proto) =~ /^ftps?$/) ? '_sockctrl.log':'_sockfilt.log'; + my $trailer = (lc($proto) =~ /^ftps?$/) ? '_sockctrl.log' : '_sockfilt.log'; return "${logdir}/". servername_canon($proto, $ipver, $idnum) ."$trailer"; } diff --git a/tests/servers.pm b/tests/servers.pm index 35cfb15725..0cc13874cc 100644 --- a/tests/servers.pm +++ b/tests/servers.pm @@ -274,7 +274,7 @@ sub checkdied { } use POSIX ":sys_wait_h"; my $rc = pidwait($pid, &WNOHANG); - return ($rc == $pid)?1:0; + return ($rc == $pid) ? 1 : 0; } ############################################################################## @@ -650,12 +650,12 @@ sub verifyftp { } # we can/should use the time it took to verify the FTP server as a measure # on how fast/slow this host/FTP is. - my $took = int(0.5+time()-$time); + my $took = int(0.5 + time() - $time); if($verbose) { logmsg "RUN: Verifying our test $server server took $took seconds\n"; } - $ftpchecktime = $took>=1?$took:1; # make sure it never is below 1 + $ftpchecktime = ($took >= 1) ? $took : 1; # make sure it never is below 1 return $pid; } diff --git a/tests/sshhelp.pm b/tests/sshhelp.pm index 56d863a105..f8cac3e75a 100644 --- a/tests/sshhelp.pm +++ b/tests/sshhelp.pm @@ -381,7 +381,7 @@ sub sshversioninfo { if($tmpstr =~ /OpenSSH[_-](\d+)\.(\d+)(\.(\d+))*/i) { $major = $1; $minor = $2; - $patch = $4?$4:0; + $patch = $4 ? $4 : 0; $sshid = 'OpenSSH'; $versnum = (100*$major) + (10*$minor) + $patch; $versstr = "$sshid $major.$minor.$patch"; @@ -391,7 +391,7 @@ sub sshversioninfo { if($tmpstr =~ /OpenSSH[_-]for[_-]Windows[_-](\d+)\.(\d+)(\.(\d+))*/i) { $major = $1; $minor = $2; - $patch = $4?$4:0; + $patch = $4 ? $4 : 0; $sshid = 'OpenSSH-Windows'; $versnum = (100*$major) + (10*$minor) + $patch; $versstr = "$sshid $major.$minor.$patch"; @@ -401,7 +401,7 @@ sub sshversioninfo { if($tmpstr =~ /Sun[_-]SSH[_-](\d+)\.(\d+)(\.(\d+))*/i) { $major = $1; $minor = $2; - $patch = $4?$4:0; + $patch = $4 ? $4 : 0; $sshid = 'SunSSH'; $versnum = (100*$major) + (10*$minor) + $patch; $versstr = "$sshid $major.$minor.$patch"; diff --git a/tests/sshserver.pl b/tests/sshserver.pl index 39e6b942ed..2132ff2d09 100755 --- a/tests/sshserver.pl +++ b/tests/sshserver.pl @@ -223,7 +223,7 @@ $logfile = "$logdir/sshserver.log"; # used by logmsg #*************************************************************************** # Logging level for ssh server and client # -my $loglevel = $debugprotocol?'DEBUG3':'DEBUG2'; +my $loglevel = $debugprotocol ? 'DEBUG3' : 'DEBUG2'; #*************************************************************************** # Validate username @@ -1193,7 +1193,7 @@ if($rc == -1) { } elsif($rc & 127) { logmsg sprintf("\"$sshd\" died with signal %d, and %s coredump\n", - ($rc & 127), ($rc & 128)?'a':'no'); + ($rc & 127), ($rc & 128) ? 'a' : 'no'); } elsif($verbose && ($rc >> 8)) { logmsg sprintf("\"$sshd\" exited with %d\n", $rc >> 8); diff --git a/tests/unit/unit1398.c b/tests/unit/unit1398.c index 951a74589f..7cab89facd 100644 --- a/tests/unit/unit1398.c +++ b/tests/unit/unit1398.c @@ -38,7 +38,9 @@ static CURLcode test_unit1398(const char *arg) int width = 3; char output[130]; - /*#define curl_msnprintf snprintf */ +#if 0 +#define curl_msnprintf snprintf +#endif /* without a trailing zero */ rc = curl_msnprintf(output, 4, "%.*s", width, buf);