tidy-up: miscellaneous

- curl_ntlm_core, smtp, schannel: fix comments.
- curl_setup.h: fix to undef before define.
- tool_doswin, server/sockfilt: reduce variables scopes.
- tool_doswin: drop an interim variable.
- windows: replace `SOCKET_ERROR` with `0` to align with rest of code.
- libssh2: rename variable to align with rest of code.
- gtls, unit1398: use `#if 0`.
- curl_trc.h, curlx/inet_ntop.h: add missing parentheses in macro
  expressions.
- ldap.c: set empty macro to `do {} while(0)`.
- examples/crawler: rename a non-CURLcode `result` variable.
- CURLINFO_TLS_SESSION: drop stray colon.
- add `const` to casts where missing.
- drop unnecessary parentheses.
- fix indent.
- quote style.
- comment style.
- whitespace, newlines, fold/unfold.

Closes #20554
This commit is contained in:
Viktor Szakats 2026-02-01 01:56:43 +01:00
parent 2a92c39a21
commit 61df5f466c
No known key found for this signature in database
88 changed files with 503 additions and 503 deletions

View file

@ -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"

View file

@ -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'

View file

@ -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;
}

View file

@ -38,6 +38,7 @@
#include <stdio.h>
#include <curl/curl.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>

View file

@ -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>

View file

@ -26,6 +26,7 @@
* </DESC>
*/
#include <stdio.h>
#include <curl/curl.h>
#ifdef USE_ABSTRACT

View file

@ -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

View file

@ -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)

View file

@ -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 ***.

View file

@ -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));
}

View file

@ -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.

View file

@ -59,7 +59,7 @@
#define HAVE_SIGACTION 1
#define CURL_DISABLE_LDAP 1
#define CURL_DISABLE_LDAP
#define HAVE_IOCTL_FIONBIO 1

View file

@ -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)
{

View file

@ -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

View file

@ -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)

View file

@ -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 */

View file

@ -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,

View file

@ -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) \

View file

@ -53,18 +53,18 @@ 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)
@ -96,9 +96,9 @@ 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 {
@ -122,10 +122,10 @@ 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,9 +147,9 @@ 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);
@ -162,7 +162,7 @@ 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;

View file

@ -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

View file

@ -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;

View file

@ -890,7 +890,7 @@ static void doh_show(struct Curl_easy *data,
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]));
}
@ -1273,7 +1273,7 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data,
#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);

View file

@ -50,7 +50,7 @@ struct dynhds {
int opts;
};
#define DYNHDS_OPT_NONE (0)
#define DYNHDS_OPT_NONE 0
#define DYNHDS_OPT_LOWERCASE (1 << 0)
/**

View file

@ -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",

View file

@ -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 */

View file

@ -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 :

View file

@ -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

View file

@ -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 {

View file

@ -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 {

View file

@ -45,7 +45,7 @@
#ifdef USE_WIN32_LDAP /* Use Windows LDAP implementation. */
# include <winldap.h>
/* Undefine indirect <wincrypt.h> symbols conflicting with BoringSSL. */
/* Undefine indirect <wincrypt.h> symbols conflicting with BoringSSL/AWS-LC. */
# undef X509_NAME
# undef X509_EXTENSIONS
# undef PKCS7_ISSUER_AND_SERIAL
@ -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

View file

@ -227,7 +227,6 @@ 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
* may not contain UTF-8 characters).
* address [in/out] - A new allocated buffer which holds the local
@ -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 = "";

View file

@ -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,

View file

@ -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);

View file

@ -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;
}

View file

@ -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.

View file

@ -185,7 +185,7 @@ typedef CURLcode (Curl_recv)(struct Curl_easy *data, /* transfer */
# include <gssapi.h>
# else /* MIT Kerberos */
# include <gssapi/gssapi.h>
# include <gssapi/gssapi_krb5.h> /* for GSS_C_CHANNEL_BOUND_FLAG, in 1.19+ */
# include <gssapi/gssapi_krb5.h> /* for GSS_C_CHANNEL_BOUND_FLAG in 1.19+ */
# endif
#endif

View file

@ -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)) {

View file

@ -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

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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;
@ -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 {
@ -4254,7 +4254,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf,
(reason == SSL_R_ECH_REQUIRED)) {
#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);

View file

@ -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"
@ -501,7 +501,7 @@ 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;
@ -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) {
@ -1677,8 +1676,8 @@ 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,
static CURLcode schannel_recv_renegotiate(
struct Curl_cfilter *cf, struct Curl_easy *data,
enum schannel_renegotiate_caller_t caller)
{
CURLcode result;

View file

@ -29,8 +29,8 @@
#ifdef USE_SCHANNEL
#include <schannel.h>
#include "../curl_sspi.h"
#include "../curl_sspi.h"
#include "../cfilters.h"
#include "../urldata.h"

View file

@ -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"

View file

@ -102,7 +102,7 @@ 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)

View file

@ -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",

View file

@ -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;

View file

@ -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)
{

View file

@ -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
}

View file

@ -67,29 +67,29 @@ 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,17 +124,17 @@ 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,32 +404,33 @@ 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;
}

View file

@ -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 &&

View file

@ -87,15 +87,14 @@ 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
@ -112,32 +111,32 @@ 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.
*/
/* ---------------------------------------------------------------- */

View file

@ -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) {

View file

@ -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) {

View file

@ -655,7 +655,7 @@ sub verifyftp {
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;
}

View file

@ -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);