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

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

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

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

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

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

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

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

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

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

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

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

View file

@ -33,7 +33,7 @@
#define MAX_SEGMENTS 128 /* number of output segments */
#ifdef __AMIGA__
# undef FORMAT_INT
#undef FORMAT_INT
#endif
/* Lower-case digits. */

View file

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

View file

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

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

View file

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

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

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

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

View file

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

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

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

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

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

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

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

View file

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

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

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