tidy-up: miscellaneous

- apply more clang-format.
- lib/version: use `CURL_ARRAYSIZE()`.
- INSTALL-CMAKE.md: sync-up an option description with others.
- examples: delete unused main args.
- examples/ftpgetinfo: document `_CRT_SECURE_NO_WARNINGS` symbol.
- delete remaining stray duplicate lines.
- acinclude.m4: drop an unnecessary x-hack.
- vtls/mbedtls: join a URL split into two lines.
- src/tool_cb_see: add parentheses around macro expressions.
- src/tool_operate: move literals to the right side of comparisons.
- libtests: sync up fopen/fstat error messages between tests.
- curl_setup.h: replace `if ! defined __LP64` with `ifndef __LP64`.
  I assume it makes no difference on Tandem systems, as the latter form
  is already used in `include/curl/system.h`.

Closes #20018
This commit is contained in:
Viktor Szakats
2025-12-12 20:51:52 +01:00
parent cd9da30e76
commit 308c347c8b
53 changed files with 988 additions and 1005 deletions

View File

@@ -1168,7 +1168,7 @@ AS_HELP_STRING([--without-ca-path], [Do not use a default CA path]),
dnl --with-ca-path given
capath="$want_capath"
ca="no"
elif test "x$ca_native" != "xno"; then
elif test "$ca_native" != "no"; then
# native ca configured, do not look further
ca="no"
capath="no"

View File

@@ -389,7 +389,7 @@ Details via CMake
- `OPENSSL_USE_STATIC_LIBS`: Look for static OpenSSL libraries.
- `ZLIB_INCLUDE_DIR`: Absolute path to zlib include directory.
- `ZLIB_LIBRARY`: Absolute path to `zlib` library.
- `ZLIB_USE_STATIC_LIBS`: Look for static ZLIB library (requires CMake v3.24).
- `ZLIB_USE_STATIC_LIBS`: Look for static `zlib` library (requires CMake v3.24).
## Dependency options (tools)

View File

@@ -451,15 +451,13 @@ void sigint_handler(int signo)
g_should_exit_ = 1;
}
int main(int argc, char **argv)
int main(void)
{
CURLcode result;
struct GlobalInfo g;
struct itimerspec its;
struct epoll_event ev;
struct epoll_event events[10];
(void)argc;
(void)argv;
result = curl_global_init(CURL_GLOBAL_ALL);
if(result)

View File

@@ -410,12 +410,10 @@ static int init_fifo(struct GlobalInfo *g)
return 0;
}
int main(int argc, char **argv)
int main(void)
{
CURLcode result;
struct GlobalInfo g;
(void)argc;
(void)argv;
result = curl_global_init(CURL_GLOBAL_ALL);
if(result)

View File

@@ -27,7 +27,7 @@
*/
#ifdef _MSC_VER
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
#define _CRT_SECURE_NO_WARNINGS /* for ctime(), fopen() */
#endif
#endif

View File

@@ -419,12 +419,10 @@ static void clean_fifo(struct GlobalInfo *g)
unlink(fifo);
}
int main(int argc, char **argv)
int main(void)
{
CURLcode result;
struct GlobalInfo g;
(void)argc;
(void)argv;
result = curl_global_init(CURL_GLOBAL_ALL);
if(result)

View File

@@ -69,7 +69,6 @@
} \
} while(0)
/* A list of connections to the same destination. */
struct cpool_bundle {
struct Curl_llist conns; /* connections in the bundle */
@@ -167,7 +166,6 @@ static struct cpool_bundle *cpool_find_bundle(struct cpool *cpool,
conn->destination, strlen(conn->destination) + 1);
}
static void cpool_remove_bundle(struct cpool *cpool,
struct cpool_bundle *bundle)
{

View File

@@ -287,8 +287,10 @@ static const struct Curl_cwtype deflate_encoding = {
sizeof(struct zlib_writer)
};
/*
* Gzip handler.
*/
/* Gzip handler. */
static CURLcode gzip_do_init(struct Curl_easy *data,
struct Curl_cwriter *writer)
{

View File

@@ -162,7 +162,7 @@
/* ================================================================ */
/* Definition of preprocessor macros/symbols which modify compiler */
/* behavior or generated code characteristics must be done here, */
/* behavior or generated code characteristics must be done here, */
/* as appropriate, before any system header file is included. It is */
/* also possible to have them defined in the config file included */
/* before this point. As a result of all this we frown inclusion of */
@@ -449,7 +449,7 @@
#include <assert.h>
#ifdef __TANDEM /* for ns*-tandem-nsk systems */
# if ! defined __LP64
# ifndef __LP64
# include <floss.h> /* FLOSS is only used for 32-bit builds. */
# endif
#endif
@@ -783,7 +783,7 @@
* Definition of our NOP statement Object-like macro
*/
#ifndef Curl_nop_stmt
#define Curl_nop_stmt do { } while(0)
#define Curl_nop_stmt do {} while(0)
#endif
/*
@@ -843,8 +843,8 @@
Therefore we specify it explicitly. https://github.com/curl/curl/pull/258
*/
#if defined(_WIN32) || defined(MSDOS)
#define FOPEN_READTEXT "rt"
#define FOPEN_WRITETEXT "wt"
#define FOPEN_READTEXT "rt"
#define FOPEN_WRITETEXT "wt"
#define FOPEN_APPENDTEXT "at"
#elif defined(__CYGWIN__)
/* Cygwin has specific behavior we need to address when _WIN32 is not defined.
@@ -853,12 +853,12 @@ For write we want our output to have line endings of LF and be compatible with
other Cygwin utilities. For read we want to handle input that may have line
endings either CRLF or LF so 't' is appropriate.
*/
#define FOPEN_READTEXT "rt"
#define FOPEN_WRITETEXT "w"
#define FOPEN_READTEXT "rt"
#define FOPEN_WRITETEXT "w"
#define FOPEN_APPENDTEXT "a"
#else
#define FOPEN_READTEXT "r"
#define FOPEN_WRITETEXT "w"
#define FOPEN_READTEXT "r"
#define FOPEN_WRITETEXT "w"
#define FOPEN_APPENDTEXT "a"
#endif
@@ -919,7 +919,10 @@ extern curl_calloc_callback Curl_ccalloc;
* This macro also assigns NULL to given pointer when free'd.
*/
#define Curl_safefree(ptr) \
do { curlx_free(ptr); (ptr) = NULL;} while(0)
do { \
curlx_free(ptr); \
(ptr) = NULL; \
} while(0)
#include <curl/curl.h> /* for CURL_EXTERN, mprintf.h */
@@ -1002,15 +1005,13 @@ CURL_EXTERN RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd,
/* FILE functions */
CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
CURL_EXTERN ALLOC_FUNC
FILE *curl_dbg_fopen(const char *file, const char *mode,
int line, const char *source);
CURL_EXTERN ALLOC_FUNC
FILE *curl_dbg_freopen(const char *file, const char *mode, FILE *fh,
int line, const char *source);
CURL_EXTERN ALLOC_FUNC
FILE *curl_dbg_fdopen(int filedes, const char *mode,
int line, const char *source);
CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fopen(const char *file, const char *mode,
int line, const char *source);
CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_freopen(const char *file,
const char *mode, FILE *fh,
int line, const char *source);
CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode,
int line, const char *source);
#define sclose(sockfd) curl_dbg_sclose(sockfd, __LINE__, __FILE__)
#define fake_sclose(sockfd) curl_dbg_mark_sclose(sockfd, __LINE__, __FILE__)
@@ -1059,47 +1060,47 @@ CURL_EXTERN ALLOC_FUNC
#ifdef CURLDEBUG
#define curlx_strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
#define curlx_malloc(size) curl_dbg_malloc(size, __LINE__, __FILE__)
#define curlx_calloc(nbelem,size) \
curl_dbg_calloc(nbelem, size, __LINE__, __FILE__)
#define curlx_realloc(ptr,size) \
curl_dbg_realloc(ptr, size, __LINE__, __FILE__)
#define curlx_free(ptr) curl_dbg_free(ptr, __LINE__, __FILE__)
#define curlx_strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
#define curlx_malloc(size) curl_dbg_malloc(size, __LINE__, __FILE__)
#define curlx_calloc(nbelem, size) \
curl_dbg_calloc(nbelem, size, __LINE__, __FILE__)
#define curlx_realloc(ptr, size) \
curl_dbg_realloc(ptr, size, __LINE__, __FILE__)
#define curlx_free(ptr) curl_dbg_free(ptr, __LINE__, __FILE__)
#ifdef _WIN32
#ifdef UNICODE
#define curlx_tcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
#define curlx_tcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
#else
#define curlx_tcsdup(ptr) curlx_strdup(ptr)
#define curlx_tcsdup(ptr) curlx_strdup(ptr)
#endif
#endif /* _WIN32 */
#else /* !CURLDEBUG */
#ifdef BUILDING_LIBCURL
#define curlx_strdup(ptr) Curl_cstrdup(ptr)
#define curlx_malloc(size) Curl_cmalloc(size)
#define curlx_calloc(nbelem,size) Curl_ccalloc(nbelem, size)
#define curlx_realloc(ptr,size) Curl_crealloc(ptr, size)
#define curlx_free(ptr) Curl_cfree(ptr)
#define curlx_strdup(ptr) Curl_cstrdup(ptr)
#define curlx_malloc(size) Curl_cmalloc(size)
#define curlx_calloc(nbelem, size) Curl_ccalloc(nbelem, size)
#define curlx_realloc(ptr, size) Curl_crealloc(ptr, size)
#define curlx_free(ptr) Curl_cfree(ptr)
#else /* !BUILDING_LIBCURL */
#ifdef _WIN32
#define curlx_strdup(ptr) _strdup(ptr)
#define curlx_strdup(ptr) _strdup(ptr)
#else
#define curlx_strdup(ptr) strdup(ptr)
#define curlx_strdup(ptr) strdup(ptr)
#endif
#define curlx_malloc(size) malloc(size)
#define curlx_calloc(nbelem,size) calloc(nbelem, size)
#define curlx_realloc(ptr,size) realloc(ptr, size)
#define curlx_free(ptr) free(ptr)
#define curlx_malloc(size) malloc(size)
#define curlx_calloc(nbelem, size) calloc(nbelem, size)
#define curlx_realloc(ptr, size) realloc(ptr, size)
#define curlx_free(ptr) free(ptr)
#endif /* BUILDING_LIBCURL */
#ifdef _WIN32
#ifdef UNICODE
#define curlx_tcsdup(ptr) Curl_wcsdup(ptr)
#define curlx_tcsdup(ptr) Curl_wcsdup(ptr)
#else
#define curlx_tcsdup(ptr) curlx_strdup(ptr)
#define curlx_tcsdup(ptr) curlx_strdup(ptr)
#endif
#endif /* _WIN32 */
@@ -1124,8 +1125,8 @@ int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
#endif
#if (defined(USE_NGTCP2) && defined(USE_NGHTTP3)) || \
(defined(USE_OPENSSL_QUIC) && defined(USE_NGHTTP3)) || \
defined(USE_QUICHE)
(defined(USE_OPENSSL_QUIC) && defined(USE_NGHTTP3)) || \
defined(USE_QUICHE)
#ifdef CURL_WITH_MULTI_SSL
#error "MultiSSL combined with QUIC is not supported"

View File

@@ -263,7 +263,7 @@ typedef unsigned int bit;
#ifdef DEBUGBUILD
#define DEBUGF(x) x
#else
#define DEBUGF(x) do { } while(0)
#define DEBUGF(x) do {} while(0)
#endif
/*
@@ -273,7 +273,7 @@ typedef unsigned int bit;
#ifdef DEBUGBUILD
#define DEBUGASSERT(x) assert(x)
#else
#define DEBUGASSERT(x) do { } while(0)
#define DEBUGASSERT(x) do {} while(0)
#endif
/*

View File

@@ -643,7 +643,6 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
}
}
if(!ev->msbump && ev->ms >= 0) {
/* If nothing updated the timeout, we decrease it by the spent time.
* If it was updated, it has the new timeout time stored already.

View File

@@ -59,7 +59,7 @@
#endif
#endif
#endif
#endif /* !__INTEL_COMPILER */
static CURL_INLINE void curl_simple_lock_lock(curl_simple_lock *lock)
{

View File

@@ -3685,7 +3685,6 @@ static CURLcode ftp_do_more(struct Curl_easy *data, int *completep)
return result;
}
/***********************************************************************
*
* ftp_perform()

View File

@@ -142,7 +142,6 @@ struct IMAP {
BIT(uidvalidity_set);
};
/* Local API functions */
static CURLcode imap_regular_transfer(struct Curl_easy *data,
struct IMAP *imap,

View File

@@ -262,7 +262,6 @@ static char *Curl_basename(char *path)
#define basename(x) Curl_basename(x)
#endif
/* Set readback state. */
static void mimesetstate(struct mime_state *state,
enum mimestate tok, void *ptr)
@@ -272,7 +271,6 @@ static void mimesetstate(struct mime_state *state,
state->offset = 0;
}
/* Escape header string into allocated memory. */
static char *escape_string(struct Curl_easy *data,
const char *src, enum mimestrategy strategy)

View File

@@ -43,7 +43,6 @@
#include "bufref.h"
#include "curlx/strparse.h"
/* meta key for storing protocol meta at easy handle */
#define CURL_META_RTSP_EASY "meta:proto:rtsp:easy"
/* meta key for storing protocol meta at connection */
@@ -72,7 +71,6 @@ struct RTSP {
long CSeq_recv; /* CSeq received */
};
#define RTP_PKT_LENGTH(p) ((((unsigned int)((unsigned char)((p)[2]))) << 8) | \
((unsigned int)((unsigned char)((p)[3]))))

View File

@@ -1703,7 +1703,6 @@ static CURLcode smtp_regular_transfer(struct Curl_easy *data,
return result;
}
static void smtp_easy_dtor(void *key, size_t klen, void *entry)
{
struct SMTP *smtp = entry;

View File

@@ -94,7 +94,6 @@
#define CURL_EMPTY 0
#define CURL_OPPOSITE 1
/* meta key for storing protocol meta at easy handle */
#define CURL_META_TELNET_EASY "meta:proto:telnet:easy"

View File

@@ -143,7 +143,6 @@ struct tftp_conn {
BIT(remote_pinned);
};
/* Forward declarations */
static CURLcode tftp_rx(struct tftp_conn *state, tftp_event_t event);
static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event);
@@ -162,7 +161,6 @@ static CURLcode tftp_translate_code(tftp_error_t error);
/*
* TFTP protocol handler.
*/
const struct Curl_handler Curl_handler_tftp = {
"tftp", /* scheme */
tftp_setup_connection, /* setup_connection */

View File

@@ -741,14 +741,14 @@ struct connectdata {
#ifndef CURL_DISABLE_PROXY
#define CURL_CONN_HOST_DISPNAME(c) \
((c)->bits.socksproxy ? (c)->socks_proxy.host.dispname : \
(c)->bits.httpproxy ? (c)->http_proxy.host.dispname : \
(c)->bits.conn_to_host ? (c)->conn_to_host.dispname : \
(c)->host.dispname)
((c)->bits.socksproxy ? (c)->socks_proxy.host.dispname : \
(c)->bits.httpproxy ? (c)->http_proxy.host.dispname : \
(c)->bits.conn_to_host ? (c)->conn_to_host.dispname : \
(c)->host.dispname)
#else
#define CURL_CONN_HOST_DISPNAME(c) \
(c)->bits.conn_to_host ? (c)->conn_to_host.dispname : \
(c)->host.dispname
(c)->bits.conn_to_host ? (c)->conn_to_host.dispname : \
(c)->host.dispname
#endif
/* The end of connectdata. */
@@ -1162,7 +1162,7 @@ enum dupstring {
STRING_SSL_CIPHER_LIST, /* list of ciphers to use */
STRING_SSL_CIPHER13_LIST, /* list of TLS 1.3 ciphers to use */
STRING_SSL_CRLFILE, /* CRL file to check certificate */
STRING_SSL_ISSUERCERT, /* issuer cert file to check certificate */
STRING_SSL_ISSUERCERT, /* issuer cert file to check certificate */
STRING_SERVICE_NAME, /* Service name */
#ifndef CURL_DISABLE_PROXY
STRING_CERT_PROXY, /* client certificate filename */

View File

@@ -551,9 +551,7 @@ static const struct feat features_table[] = {
{NULL, NULL, 0}
};
static const char *feature_names[sizeof(features_table) /
sizeof(features_table[0])] = {NULL};
static const char *feature_names[CURL_ARRAYSIZE(features_table)] = { NULL };
static curl_version_info_data version_info = {
CURLVERSION_NOW,

View File

@@ -54,7 +54,6 @@
#define NW_CHUNK_SIZE (64 * 1024)
#define NW_SEND_CHUNKS 1
int Curl_vquic_init(void)
{
#if defined(USE_NGTCP2) && defined(OPENSSL_QUIC_API2)

View File

@@ -282,7 +282,6 @@ static const char *myssh_statename(sshstate state)
#define myssh_statename(x) ""
#endif /* !CURL_DISABLE_VERBOSE_STRINGS */
#define myssh_to(x, y, z) myssh_set_state(x, y, z)
/*

View File

@@ -123,7 +123,6 @@ const struct Curl_handler Curl_handler_scp = {
PROTOPT_NOURLQUERY | PROTOPT_CONN_REUSE
};
/*
* SFTP protocol handler.
*/
@@ -353,7 +352,6 @@ static const char *myssh_statename(sshstate state)
#define myssh_statename(x) ""
#endif /* !CURL_DISABLE_VERBOSE_STRINGS */
#define myssh_state(x, y, z) myssh_set_state(x, y, z)
/*

View File

@@ -229,9 +229,9 @@ static const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_fr = {
1024, /* RSA min key len */
};
/* See https://web.archive.org/web/20200921194007/tls.mbed.org/discussions/
generic/howto-determine-exact-buffer-len-for-mbedtls_pk_write_pubkey_der
*/
/* See:
* https://web.archive.org/web/20200921194007/tls.mbed.org/discussions/generic/howto-determine-exact-buffer-len-for-mbedtls_pk_write_pubkey_der
*/
#define RSA_PUB_DER_MAX_BYTES (38 + 2 * MBEDTLS_MPI_MAX_SIZE)
#define ECP_PUB_DER_MAX_BYTES (30 + 2 * MBEDTLS_ECP_MAX_BYTES)

View File

@@ -1443,7 +1443,6 @@ fail:
return 1;
}
static CURLcode client_cert(struct Curl_easy *data,
SSL_CTX* ctx,
char *cert_file,
@@ -3629,7 +3628,6 @@ static CURLcode ossl_init_ssl(struct ossl_ctx *octx,
alpns_requested, sess_reuse_cb);
}
static CURLcode ossl_init_method(struct Curl_cfilter *cf,
struct Curl_easy *data,
struct ssl_peer *peer,
@@ -3828,7 +3826,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
OpenSSL supports processing "jumbo TLS record" (8 TLS records) in one go
for some algorithms, so match that here.
Experimentation shows that a slightly larger buffer is needed
to avoid short reads.
to avoid short reads.
However using a large buffer (8 packets) actually decreases performance.
4 packets is better.
@@ -4669,7 +4667,6 @@ out:
}
#endif /* ! CURL_DISABLE_VERBOSE_STRINGS */
#ifdef USE_APPLE_SECTRUST
struct ossl_certs_ctx {
STACK_OF(X509) *sk;

View File

@@ -70,8 +70,8 @@
#define SCH_DEV_SHOWBOOL(x) \
infof(data, "schannel: " #x " %s", (x) ? "TRUE" : "FALSE");
#else
#define SCH_DEV(x) do { } while(0)
#define SCH_DEV_SHOWBOOL(x) do { } while(0)
#define SCH_DEV(x) do {} while(0)
#define SCH_DEV_SHOWBOOL(x) do {} while(0)
#endif
/* Offered by mingw-w64 v8+. MS SDK 7.0A+. */

View File

@@ -36,7 +36,6 @@
#include <wolfssl/options.h>
#include <wolfssl/version.h>
#if LIBWOLFSSL_VERSION_HEX < 0x03004006 /* wolfSSL 3.4.6 (2015) */
#error "wolfSSL version should be at least 3.4.6"
#endif

View File

@@ -92,7 +92,6 @@
/* #define CURL_ASN1_CHARACTER_STRING 29 */
#define CURL_ASN1_BMP_STRING 30
#ifdef WANT_EXTRACT_CERTINFO
/* ASN.1 OID table entry. */
struct Curl_OID {

View File

@@ -43,7 +43,6 @@
#include "curlx/strparse.h"
#include "curlx/warnless.h"
/***
RFC 6455 Section 5.2
@@ -770,7 +769,6 @@ static const struct Curl_cwtype ws_cw_decode = {
sizeof(struct ws_cw_ctx)
};
static void ws_enc_info(struct ws_encoder *enc, struct Curl_easy *data,
const char *msg)
{

View File

@@ -184,6 +184,7 @@ AC_DEFUN([CURL_CHECK_NEED_REENTRANT_STRERROR_R], [
fi
])
dnl CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
dnl -------------------------------------------------
dnl Checks if the preprocessor _REENTRANT definition

View File

@@ -1127,7 +1127,7 @@ HEAD
$bitmask .= ' | ';
}
}
$bitmask =~ s/(?=.{76}).{1,76}\|/$&\n /g;
$bitmask =~ s/(?=.{76}).{1,76}\|/$&\n /g;
my $arg = $arglong{$long};
if($arg) {
$opt .= " $arg";
@@ -1135,7 +1135,7 @@ HEAD
my $desc = $helplong{$f};
$desc =~ s/\"/\\\"/g; # escape double quotes
my $line = sprintf " {\"%s\",\n \"%s\",\n %s},\n", $opt, $desc, $bitmask;
my $line = sprintf " { \"%s\",\n \"%s\",\n %s },\n", $opt, $desc, $bitmask;
if(length($opt) > 78) {
print STDERR "WARN: the --$long name is too long\n";

View File

@@ -229,8 +229,7 @@ int tool_progress_cb(void *clientp,
return 0;
}
void progressbarinit(struct ProgressData *bar,
struct OperationConfig *config)
void progressbarinit(struct ProgressData *bar, struct OperationConfig *config)
{
memset(bar, 0, sizeof(struct ProgressData));

View File

@@ -42,8 +42,7 @@ struct ProgressData {
struct OperationConfig;
void progressbarinit(struct ProgressData *bar,
struct OperationConfig *config);
void progressbarinit(struct ProgressData *bar, struct OperationConfig *config);
/*
** callback for CURLOPT_PROGRESSFUNCTION

View File

@@ -44,8 +44,8 @@ int tool_seek_cb(void *userdata, curl_off_t offset, int whence)
both represent the same value. Maximum offset used here when we lseek
using a 'long' data type offset */
#define OUR_MAX_SEEK_L 2147483647L - 1L
#define OUR_MAX_SEEK_O 0x7FFFFFFF - 0x1
#define OUR_MAX_SEEK_L (2147483647L - 1L)
#define OUR_MAX_SEEK_O (0x7FFFFFFF - 0x1)
/* The offset check following here is only interesting if curl_off_t is
larger than off_t and we are not using the Win32 large file support

View File

@@ -38,7 +38,7 @@
#endif
#endif
#define MAX_CONFIG_LINE_LENGTH (10*1024*1024)
#define MAX_CONFIG_LINE_LENGTH (10 * 1024 * 1024)
#define checkprefix(a, b) curl_strnequal(b, STRCONST(a))

View File

@@ -44,8 +44,7 @@ int getfiletime(const char *filename, curl_off_t *stamp)
TCHAR *tchar_filename = curlx_convert_UTF8_to_tchar(filename);
hfile = CreateFile(tchar_filename, FILE_READ_ATTRIBUTES,
(FILE_SHARE_READ | FILE_SHARE_WRITE |
FILE_SHARE_DELETE),
(FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE),
NULL, OPEN_EXISTING, 0, NULL);
curlx_free(tchar_filename);
if(hfile != INVALID_HANDLE_VALUE) {
@@ -110,8 +109,7 @@ void setfiletime(curl_off_t filetime, const char *filename)
}
hfile = CreateFile(tchar_filename, FILE_WRITE_ATTRIBUTES,
(FILE_SHARE_READ | FILE_SHARE_WRITE |
FILE_SHARE_DELETE),
(FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE),
NULL, OPEN_EXISTING, 0, NULL);
curlx_free(tchar_filename);
if(hfile != INVALID_HANDLE_VALUE) {

View File

@@ -840,9 +840,9 @@ int formparse(const char *input,
part->headers = headers;
headers = NULL;
if(res == CURLE_READ_ERROR) {
/* An error occurred while reading stdin: if read has started,
issue the error now. Else, delay it until processed by
libcurl. */
/* An error occurred while reading stdin: if read has started,
issue the error now. Else, delay it until processed by
libcurl. */
if(part->size > 0) {
warnf("error while reading standard input");
goto fail;

View File

@@ -61,7 +61,7 @@ static struct proto_name_tokenp {
{ "scp", &proto_scp },
{ "sftp", &proto_sftp },
{ "tftp", &proto_tftp },
{ NULL, NULL }
{ NULL, NULL }
};
bool feature_altsvc = FALSE;
@@ -87,38 +87,38 @@ static struct feature_name_presentp {
int feature_bitmask;
} const maybe_feature[] = {
/* Keep alphabetically sorted. */
{"alt-svc", &feature_altsvc, CURL_VERSION_ALTSVC},
{"AsynchDNS", NULL, CURL_VERSION_ASYNCHDNS},
{"brotli", &feature_brotli, CURL_VERSION_BROTLI},
{"CharConv", NULL, CURL_VERSION_CONV},
{"Debug", NULL, CURL_VERSION_DEBUG},
{"ECH", &feature_ech, 0},
{"gsasl", NULL, CURL_VERSION_GSASL},
{"GSS-API", NULL, CURL_VERSION_GSSAPI},
{"HSTS", &feature_hsts, CURL_VERSION_HSTS},
{"HTTP2", &feature_http2, CURL_VERSION_HTTP2},
{"HTTP3", &feature_http3, CURL_VERSION_HTTP3},
{"HTTPS-proxy", &feature_httpsproxy, CURL_VERSION_HTTPS_PROXY},
{"IDN", NULL, CURL_VERSION_IDN},
{"IPv6", NULL, CURL_VERSION_IPV6},
{"Kerberos", NULL, CURL_VERSION_KERBEROS5},
{"Largefile", NULL, CURL_VERSION_LARGEFILE},
{"libz", &feature_libz, CURL_VERSION_LIBZ},
{"MultiSSL", NULL, CURL_VERSION_MULTI_SSL},
{"NTLM", &feature_ntlm, CURL_VERSION_NTLM},
{"NTLM_WB", &feature_ntlm_wb, CURL_VERSION_NTLM_WB},
{"PSL", NULL, CURL_VERSION_PSL},
{"SPNEGO", &feature_spnego, CURL_VERSION_SPNEGO},
{"SSL", &feature_ssl, CURL_VERSION_SSL},
{"SSPI", NULL, CURL_VERSION_SSPI},
{"SSLS-EXPORT", &feature_ssls_export, 0},
{"threadsafe", NULL, CURL_VERSION_THREADSAFE},
{"TLS-SRP", &feature_tls_srp, CURL_VERSION_TLSAUTH_SRP},
{"TrackMemory", NULL, CURL_VERSION_CURLDEBUG},
{"Unicode", NULL, CURL_VERSION_UNICODE},
{"UnixSockets", NULL, CURL_VERSION_UNIX_SOCKETS},
{"zstd", &feature_zstd, CURL_VERSION_ZSTD},
{NULL, NULL, 0}
{ "alt-svc", &feature_altsvc, CURL_VERSION_ALTSVC },
{ "AsynchDNS", NULL, CURL_VERSION_ASYNCHDNS },
{ "brotli", &feature_brotli, CURL_VERSION_BROTLI },
{ "CharConv", NULL, CURL_VERSION_CONV },
{ "Debug", NULL, CURL_VERSION_DEBUG },
{ "ECH", &feature_ech, 0 },
{ "gsasl", NULL, CURL_VERSION_GSASL },
{ "GSS-API", NULL, CURL_VERSION_GSSAPI },
{ "HSTS", &feature_hsts, CURL_VERSION_HSTS },
{ "HTTP2", &feature_http2, CURL_VERSION_HTTP2 },
{ "HTTP3", &feature_http3, CURL_VERSION_HTTP3 },
{ "HTTPS-proxy", &feature_httpsproxy, CURL_VERSION_HTTPS_PROXY },
{ "IDN", NULL, CURL_VERSION_IDN },
{ "IPv6", NULL, CURL_VERSION_IPV6 },
{ "Kerberos", NULL, CURL_VERSION_KERBEROS5 },
{ "Largefile", NULL, CURL_VERSION_LARGEFILE },
{ "libz", &feature_libz, CURL_VERSION_LIBZ },
{ "MultiSSL", NULL, CURL_VERSION_MULTI_SSL },
{ "NTLM", &feature_ntlm, CURL_VERSION_NTLM },
{ "NTLM_WB", &feature_ntlm_wb, CURL_VERSION_NTLM_WB },
{ "PSL", NULL, CURL_VERSION_PSL },
{ "SPNEGO", &feature_spnego, CURL_VERSION_SPNEGO },
{ "SSL", &feature_ssl, CURL_VERSION_SSL },
{ "SSPI", NULL, CURL_VERSION_SSPI },
{ "SSLS-EXPORT", &feature_ssls_export, 0 },
{ "threadsafe", NULL, CURL_VERSION_THREADSAFE },
{ "TLS-SRP", &feature_tls_srp, CURL_VERSION_TLSAUTH_SRP },
{ "TrackMemory", NULL, CURL_VERSION_CURLDEBUG },
{ "Unicode", NULL, CURL_VERSION_UNICODE },
{ "UnixSockets", NULL, CURL_VERSION_UNIX_SOCKETS },
{ "zstd", &feature_zstd, CURL_VERSION_ZSTD },
{ NULL, NULL, 0 }
};
static const char *fnames[CURL_ARRAYSIZE(maybe_feature)];
@@ -186,7 +186,7 @@ CURLcode get_libcurl_info(void)
}
feature_libssh2 = curlinfo->libssh_version &&
!strncmp("libssh2", curlinfo->libssh_version, 7);
!strncmp("libssh2", curlinfo->libssh_version, 7);
return CURLE_OK;
}

File diff suppressed because it is too large Load Diff

View File

@@ -32,13 +32,10 @@
#define NOTE_PREFIX "Note: "
#define ERROR_PREFIX "curl: "
static void voutf(const char *prefix,
const char *fmt,
va_list ap) CURL_PRINTF(2, 0);
static void voutf(const char *prefix, const char *fmt, va_list ap)
CURL_PRINTF(2, 0);
static void voutf(const char *prefix,
const char *fmt,
va_list ap)
static void voutf(const char *prefix, const char *fmt, va_list ap)
{
size_t len;
char *ptr;

View File

@@ -377,21 +377,21 @@ static CURLcode retrycheck(struct OperationConfig *config,
RETRY_FTP,
RETRY_LAST /* not used */
} retry = RETRY_NO;
if((CURLE_OPERATION_TIMEDOUT == result) ||
(CURLE_COULDNT_RESOLVE_HOST == result) ||
(CURLE_COULDNT_RESOLVE_PROXY == result) ||
(CURLE_FTP_ACCEPT_TIMEOUT == result))
if((result == CURLE_OPERATION_TIMEDOUT) ||
(result == CURLE_COULDNT_RESOLVE_HOST) ||
(result == CURLE_COULDNT_RESOLVE_PROXY) ||
(result == CURLE_FTP_ACCEPT_TIMEOUT))
/* retry timeout always */
retry = RETRY_TIMEOUT;
else if(config->retry_connrefused &&
(CURLE_COULDNT_CONNECT == result)) {
(result == CURLE_COULDNT_CONNECT)) {
long oserrno = 0;
curl_easy_getinfo(curl, CURLINFO_OS_ERRNO, &oserrno);
if(SOCKECONNREFUSED == oserrno)
retry = RETRY_CONNREFUSED;
}
else if((CURLE_OK == result) ||
(config->fail && (CURLE_HTTP_RETURNED_ERROR == result))) {
else if((result == CURLE_OK) ||
(config->fail && (result == CURLE_HTTP_RETURNED_ERROR))) {
/* If it returned OK. _or_ failonerror was enabled and it
returned due to such an error, check for HTTP transient
errors to retry on. */

View File

@@ -306,10 +306,18 @@ ParameterError secs2ms(long *valp, const char *str)
{
curl_off_t secs;
long ms = 0;
const unsigned int digs[] = { 1, 10, 100, 1000, 10000, 100000,
1000000, 10000000, 100000000 };
if(!str ||
curlx_str_number(&str, &secs, LONG_MAX / 1000 - 1))
const unsigned int digs[] = {
1,
10,
100,
1000,
10000,
100000,
1000000,
10000000,
100000000
};
if(!str || curlx_str_number(&str, &secs, LONG_MAX / 1000 - 1))
return PARAM_BAD_NUMERIC;
if(!curlx_str_single(&str, '.')) {
curl_off_t fracs;

View File

@@ -73,7 +73,7 @@ extern FILE *tool_stderr;
#endif
#ifndef tool_nop_stmt
#define tool_nop_stmt do { } while(0)
#define tool_nop_stmt do {} while(0)
#endif
#ifdef _WIN32

View File

@@ -34,8 +34,7 @@
Return 0 on success, non-zero on error.
*/
int jsonquoted(const char *in, size_t len,
struct dynbuf *out, bool lowercase)
int jsonquoted(const char *in, size_t len, struct dynbuf *out, bool lowercase)
{
const unsigned char *i = (const unsigned char *)in;
const unsigned char *in_end = &i[len];

View File

@@ -26,8 +26,7 @@
#include "tool_setup.h"
#include "tool_writeout.h"
int jsonquoted(const char *in, size_t len,
struct dynbuf *out, bool lowercase);
int jsonquoted(const char *in, size_t len, struct dynbuf *out, bool lowercase);
void ourWriteOutJSON(FILE *stream, const struct writeoutvar mappings[],
size_t nentries,

View File

@@ -52,7 +52,7 @@ static CURLcode test_lib505(const char *URL)
hd_src = curlx_fopen(libtest_arg2, "rb");
if(!hd_src) {
curl_mfprintf(stderr, "fopen failed with error (%d) %s\n",
curl_mfprintf(stderr, "fopen() failed with error (%d) %s\n",
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
curl_mfprintf(stderr, "Error opening file '%s'\n", libtest_arg2);
return TEST_ERR_MAJOR_BAD; /* if this happens things are major weird */

View File

@@ -43,7 +43,7 @@ static CURLcode test_lib525(const char *URL)
hd_src = curlx_fopen(libtest_arg2, "rb");
if(!hd_src) {
curl_mfprintf(stderr, "fopen failed with error (%d) %s\n",
curl_mfprintf(stderr, "fopen() failed with error (%d) %s\n",
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
curl_mfprintf(stderr, "Error opening file '%s'\n", libtest_arg2);
return TEST_ERR_FOPEN;

View File

@@ -43,7 +43,7 @@ static CURLcode test_lib541(const char *URL)
hd_src = curlx_fopen(libtest_arg2, "rb");
if(!hd_src) {
curl_mfprintf(stderr, "fopen failed with error (%d) %s\n",
curl_mfprintf(stderr, "fopen() failed with error (%d) %s\n",
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
curl_mfprintf(stderr, "Error opening file '%s'\n", libtest_arg2);
return TEST_ERR_MAJOR_BAD; /* if this happens things are major weird */

View File

@@ -32,6 +32,7 @@ static CURLcode test_lib568(const char *URL)
{
CURLcode result;
CURL *curl;
char errbuf[STRERROR_LEN];
int sdp;
FILE *sdpf = NULL;
struct_stat file_info;
@@ -67,7 +68,9 @@ static CURLcode test_lib568(const char *URL)
sdp = curlx_open(libtest_arg2, O_RDONLY);
if(sdp == -1) {
curl_mfprintf(stderr, "cannot open %s\n", libtest_arg2);
curl_mfprintf(stderr, "open() failed with error (%d) %s\n",
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
curl_mfprintf(stderr, "Error opening file '%s'\n", libtest_arg2);
result = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
@@ -76,7 +79,9 @@ static CURLcode test_lib568(const char *URL)
sdpf = curlx_fopen(libtest_arg2, "rb");
if(!sdpf) {
curl_mfprintf(stderr, "cannot fopen %s\n", libtest_arg2);
curl_mfprintf(stderr, "fopen() failed with error (%d) %s\n",
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
curl_mfprintf(stderr, "Error opening file '%s'\n", libtest_arg2);
result = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}

View File

@@ -32,6 +32,7 @@ static CURLcode test_lib572(const char *URL)
{
CURLcode result;
CURL *curl;
char errbuf[STRERROR_LEN];
int params;
FILE *paramsf = NULL;
struct_stat file_info;
@@ -85,7 +86,9 @@ static CURLcode test_lib572(const char *URL)
/* PUT style GET_PARAMETERS */
params = curlx_open(libtest_arg2, O_RDONLY);
if(params == -1) {
curl_mfprintf(stderr, "cannot open %s\n", libtest_arg2);
curl_mfprintf(stderr, "open() failed with error (%d) %s\n",
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
curl_mfprintf(stderr, "Error opening file '%s'\n", libtest_arg2);
result = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
@@ -94,7 +97,9 @@ static CURLcode test_lib572(const char *URL)
paramsf = curlx_fopen(libtest_arg2, "rb");
if(!paramsf) {
curl_mfprintf(stderr, "cannot fopen %s\n", libtest_arg2);
curl_mfprintf(stderr, "fopen() failed with error (%d) %s\n",
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
curl_mfprintf(stderr, "Error opening file '%s'\n", libtest_arg2);
result = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}

View File

@@ -264,7 +264,7 @@ my @toolhelp; # store all parsed parameters
while(<$r>) {
chomp;
my $l= $_;
if(/^ \{\" *(.*)/) {
if(/^ \{ \" *(.*)/) {
my $str=$1;
my $combo;
if($str =~ /^-(.), --([a-z0-9.-]*)/) {

View File

@@ -126,6 +126,7 @@ static CURLcode test_unit1664(const char *arg)
i, orgline, rc, (int)(line - orgline));
}
}
{
static const char *single[] = {
"a",
@@ -169,6 +170,7 @@ static CURLcode test_unit1664(const char *arg)
i, orgline, rc, (int)(line - orgline));
}
}
{
static const char *nums[] = {
"1",