tidy-up: miscellaneous
No binary (build failed)
—
(log yok)
| @@ -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" | |
| @@ -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' | |
| @@ -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 | |
| } | |
| ]],[ | |
| @@ -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; | |
| } | |
| @@ -38,6 +38,7 @@ | |
| #include <stdio.h> | |
| #include <curl/curl.h> | |
| + | |
| #include <gnutls/gnutls.h> | |
| #include <gnutls/x509.h> | |
| @@ -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 <stdio.h> | |
| #include <gtk/gtk.h> | |
| #include <glib.h> | |
| @@ -26,6 +26,7 @@ | |
| * </DESC> | |
| */ | |
| #include <stdio.h> | |
| + | |
| #include <curl/curl.h> | |
| #ifdef USE_ABSTRACT | |
| @@ -39,10 +39,10 @@ | |
| #include <openssl/ssl.h> | |
| - | #include <curl/curl.h> |
| - | |
| #include <stdio.h> | |
| + | #include <curl/curl.h> |
| + | |
| #if defined(__GNUC__) || defined(__clang__) | |
| #pragma GCC diagnostic ignored "-Woverlength-strings" | |
| #endif | |
| @@ -27,6 +27,7 @@ | |
| */ | |
| #include <stdio.h> | |
| #include <string.h> | |
| + | |
| #include <curl/curl.h> | |
| static size_t write_cb(char *b, size_t size, size_t nitems, void *p) | |
| @@ -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" : ""); |
| } | |
| } | |
| } | |
| @@ -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 " : ""); |
| } | |
| } | |
| } | |
| @@ -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 " : ""); |
| } | |
| } | |
| } | |
| @@ -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 ***. | |
| @@ -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)); | |
| } | |
| @@ -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. | |
| @@ -59,7 +59,7 @@ | |
| #define HAVE_SIGACTION 1 | |
| - | #define CURL_DISABLE_LDAP 1 |
| + | #define CURL_DISABLE_LDAP |
| #define HAVE_IOCTL_FIONBIO 1 | |
| @@ -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) | |
| @@ -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) | |
| { | |
| @@ -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 | |
| @@ -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) | |
| @@ -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 */ | |
| @@ -34,7 +34,7 @@ | |
| int curlx_fseek(void *stream, curl_off_t offset, int whence); | |
| #ifdef _WIN32 | |
| - | #include <sys/stat.h> /* for _fstati64, struct _stati64 */ |
| + | #include <sys/stat.h> /* for _fstati64(), struct _stati64 */ |
| #ifndef CURL_WINDOWS_UWP | |
| HANDLE curlx_CreateFile(const char *filename, | |
| DWORD dwDesiredAccess, | |
| @@ -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) \ | |
| @@ -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; | |
| } | |
| @@ -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 | |
| @@ -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; | |
| @@ -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); | |
| @@ -50,7 +50,7 @@ struct dynhds { | |
| int opts; | |
| }; | |
| - | #define DYNHDS_OPT_NONE (0) |
| + | #define DYNHDS_OPT_NONE 0 |
| #define DYNHDS_OPT_LOWERCASE (1 << 0) | |
| /** | |
| @@ -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", | |
| @@ -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 */ | |
| @@ -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; | |
| } | |
| @@ -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 : | |
| @@ -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 | |
| @@ -33,12 +33,12 @@ | |
| #include "curlx/strparse.h" | |
| /* | |
| - | * Chunk format (simplified): |
| - | * |
| - | * <HEX SIZE>[ chunk extension ] CRLF |
| - | * <DATA> CRLF |
| - | * |
| - | * Highlights from RFC2616 section 3.6 say: |
| + | Chunk format (simplified): |
| + | |
| + | <HEX SIZE>[ chunk extension ] CRLF |
| + | <DATA> 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; | |
| } | |
| @@ -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 { | |
| @@ -44,24 +44,24 @@ | |
| */ | |
| #ifdef USE_WIN32_LDAP /* Use Windows LDAP implementation. */ | |
| - | # include <winldap.h> |
| - | /* Undefine indirect <wincrypt.h> 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 <winber.h> |
| + | # include <winldap.h> |
| + | /* Undefine indirect <wincrypt.h> 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 <winber.h> |
| #else | |
| - | # define LDAP_DEPRECATED 1 /* Be sure ldap_init() is defined. */ |
| - | # ifdef HAVE_LBER_H |
| - | # include <lber.h> |
| - | # endif |
| - | # include <ldap.h> |
| - | # if defined(HAVE_LDAP_SSL) && defined(HAVE_LDAP_SSL_H) |
| - | # include <ldap_ssl.h> |
| - | # endif /* HAVE_LDAP_SSL && HAVE_LDAP_SSL_H */ |
| + | # define LDAP_DEPRECATED 1 /* Be sure ldap_init() is defined. */ |
| + | # ifdef HAVE_LBER_H |
| + | # include <lber.h> |
| + | # endif |
| + | # include <ldap.h> |
| + | # if defined(HAVE_LDAP_SSL) && defined(HAVE_LDAP_SSL_H) |
| + | # include <ldap_ssl.h> |
| + | # 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 | |
| @@ -33,7 +33,7 @@ | |
| #define MAX_SEGMENTS 128 /* number of output segments */ | |
| #ifdef __AMIGA__ | |
| - | # undef FORMAT_INT |
| + | #undef FORMAT_INT |
| #endif | |
| /* Lower-case digits. */ | |
| @@ -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; | |
| @@ -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 = ""; | |
| @@ -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")); | |
| @@ -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")); | |
| @@ -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); | |
| @@ -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; | |
| } | |
| @@ -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; | |
| @@ -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); | |
| } | |
| @@ -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 <gss.h> |
| - | # elif defined(HAVE_GSSAPI_H) |
| - | # include <gssapi.h> |
| - | # else /* MIT Kerberos */ |
| - | # include <gssapi/gssapi.h> |
| - | # include <gssapi/gssapi_krb5.h> /* for GSS_C_CHANNEL_BOUND_FLAG, in 1.19+ */ |
| - | # endif |
| + | # ifdef HAVE_GSSGNU |
| + | # include <gss.h> |
| + | # elif defined(HAVE_GSSAPI_H) |
| + | # include <gssapi.h> |
| + | # else /* MIT Kerberos */ |
| + | # include <gssapi/gssapi.h> |
| + | # include <gssapi/gssapi_krb5.h> /* for GSS_C_CHANNEL_BOUND_FLAG in 1.19+ */ |
| + | # endif |
| #endif | |
| #ifdef USE_LIBSSH2 | |
| @@ -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)) { | |
| @@ -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 | |
| @@ -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) && | |
| @@ -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); | |
| } | |
| } | |
| @@ -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; | |
| @@ -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); | |
| @@ -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]; | |
| @@ -29,8 +29,8 @@ | |
| #ifdef USE_SCHANNEL | |
| #include <schannel.h> | |
| - | #include "../curl_sspi.h" |
| + | #include "../curl_sspi.h" |
| #include "../cfilters.h" | |
| #include "../urldata.h" | |
| @@ -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" | |
| @@ -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 */ | |
| @@ -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 { | |
| @@ -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", | |
| @@ -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; | |
| @@ -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); | |
| } | |
| @@ -82,9 +82,9 @@ m4_define([AC_LANG_FUNC_LINK_TRY(C)], | |
| [ | |
| #define $1 innocuous_$1 | |
| #ifdef __STDC__ | |
| - | # include <limits.h> |
| + | # include <limits.h> |
| #else | |
| - | # include <assert.h> |
| + | # include <assert.h> |
| #endif | |
| #undef $1 | |
| #ifdef __cplusplus | |
| @@ -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"; | |
| @@ -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"; | |
| @@ -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}) { | |
| @@ -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)" : ""; |
| } | |
| } | |
| @@ -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 { | |
| @@ -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++; | |
| } | |
| @@ -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 | |
| @@ -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; | |
| } | |
| @@ -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; | |
| } | |
| } | |
| @@ -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 | |
| } | |
| @@ -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; | |
| } | |
| @@ -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 && | |
| @@ -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. */ | |
| @@ -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; | |
| @@ -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) | |
| @@ -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)); | |
| @@ -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) { | |
| @@ -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 | |
| @@ -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) { | |
| @@ -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 | |
| @@ -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 | |
| @@ -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) { | |
| @@ -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"; | |
| } | |
| @@ -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; | |
| } | |
| @@ -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"; | |
| @@ -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); | |
| @@ -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); | |