tidy-up: miscellaneous

- INSTALL-CMAKE.md: add missing periods, text fixes.
- md4, md5: sync variables names.
- curl_trc: sync an argument type.
- docs/examples: sync debug/trace function copies, constify, tidy-ups.
- replace commented code with `#if 0`.
- drop redundant parenthesis (macro values, `return`, around single
  variables, function calls).
- fix indentation, apply clang-format in places.

Closes #20481
This commit is contained in:
Viktor Szakats 2026-01-23 12:59:42 +01:00
parent ca5efd02b6
commit 3003c32cb2
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
62 changed files with 291 additions and 281 deletions

View file

@ -511,8 +511,8 @@ Examples:
## Feature detection variables
By default this CMake build script detects the version of some dependencies
using `check_symbol_exists`. Those checks do not work in the case that both
By default the curl CMake build script detects the version of some dependencies
using `check_symbol_exists()`. Those checks do not work in the case that both
CURL and its dependency are included as sub-projects in a larger build using
`FetchContent`. To support that case, additional variables may be defined by
the parent project, ideally in the "extra" find package redirect file:
@ -559,13 +559,13 @@ Note: These variables are internal and subject to change.
- `curl-examples`: Build examples
Individual targets: `curl-example-<name>`,
where <name> is the .c filename without extension.
- `curl-examples-build`: Build examples quickly but without the ability to run them (for build tests)
- `curl-man`: Build man pages (built by default unless disabled)
- `curl_uninstall`: Uninstall curl
- `curl-completion-fish`: Build shell completions for fish (built by default if enabled)
- `curl-completion-zsh`: Build shell completions for zsh (built by default if enabled)
- `curl-ca-bundle`: Build the CA bundle via `scripts/mk-ca-bundle.pl`
- `curl-ca-firefox`: Build the CA bundle via `scripts/firefox-db2pem.sh`
- `curl-examples-build`: Build examples quickly but without the ability to run them. (for build tests)
- `curl-man`: Build man pages. (built by default unless disabled)
- `curl_uninstall`: Uninstall curl.
- `curl-completion-fish`: Build shell completions for fish. (built by default if enabled)
- `curl-completion-zsh`: Build shell completions for zsh. (built by default if enabled)
- `curl-ca-bundle`: Build the CA bundle via `scripts/mk-ca-bundle.pl`.
- `curl-ca-firefox`: Build the CA bundle via `scripts/firefox-db2pem.sh`.
- `curl-lint`: Run lint checks.
- `curl-listcats`: Generate help category constants for `src/tool_help.h` from documentation.
- `curl-listhelp`: Generate `src/tool_listhelp.c` from documentation.

View file

@ -229,8 +229,7 @@ static int is_ipv4_mapped_ipv6_address(int family, void *netaddr)
}
#endif /* AF_INET6 */
static curl_socket_t opensocket(void *clientp,
curlsocktype purpose,
static curl_socket_t opensocket(void *clientp, curlsocktype purpose,
struct curl_sockaddr *address)
{
/* filter the address */

View file

@ -33,7 +33,7 @@ struct data {
char trace_ascii; /* 1 or 0 */
};
static void dump(const char *text, FILE *stream, unsigned char *ptr,
static void dump(const char *text, const unsigned char *ptr,
size_t size, char nohex)
{
size_t i;
@ -45,20 +45,20 @@ static void dump(const char *text, FILE *stream, unsigned char *ptr,
/* without the hex output, we can fit more on screen */
width = 0x40;
fprintf(stream, "%s, %10.10lu bytes (0x%8.8lx)\n",
fprintf(stderr, "%s, %10.10lu bytes (0x%8.8lx)\n",
text, (unsigned long)size, (unsigned long)size);
for(i = 0; i < size; i += width) {
fprintf(stream, "%4.4lx: ", (unsigned long)i);
fprintf(stderr, "%4.4lx: ", (unsigned long)i);
if(!nohex) {
/* hex not disabled, show it */
for(c = 0; c < width; c++)
if(i + c < size)
fprintf(stream, "%02x ", ptr[i + c]);
fprintf(stderr, "%02x ", ptr[i + c]);
else
fputs(" ", stream);
fputs(" ", stderr);
}
for(c = 0; (c < width) && (i + c < size); c++) {
@ -68,7 +68,7 @@ static void dump(const char *text, FILE *stream, unsigned char *ptr,
i += (c + 2 - width);
break;
}
fprintf(stream, "%c",
fprintf(stderr, "%c",
(ptr[i + c] >= 0x20) && (ptr[i + c] < 0x80) ? ptr[i + c] : '.');
/* check again for 0D0A, to avoid an extra \n if it is at width */
if(nohex && (i + c + 2 < size) && ptr[i + c + 1] == 0x0D &&
@ -77,9 +77,8 @@ static void dump(const char *text, FILE *stream, unsigned char *ptr,
break;
}
}
fputc('\n', stream); /* newline */
fputc('\n', stderr); /* newline */
}
fflush(stream);
}
static int my_trace(CURL *curl, curl_infotype type,
@ -115,7 +114,7 @@ static int my_trace(CURL *curl, curl_infotype type,
return 0;
}
dump(text, stderr, (unsigned char *)data, size, config->trace_ascii);
dump(text, (const unsigned char *)data, size, config->trace_ascii);
return 0;
}

View file

@ -133,7 +133,9 @@ int main(int argc, char **argv)
curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);
/* curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); */
#if 0
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
#endif
/* set a URL containing wildcard pattern (only in the last part) */
if(argc == 2)

View file

@ -47,7 +47,8 @@ static size_t throw_away(void *ptr, size_t size, size_t nmemb, void *data)
int main(void)
{
char ftpurl[] = "ftp://ftp.example.com/gnu/binutils/binutils-2.19.1.tar.bz2";
static const char ftpurl[] =
"ftp://ftp.example.com/gnu/binutils/binutils-2.19.1.tar.bz2";
CURL *curl;
CURLcode result;
long filetime = -1;
@ -68,7 +69,9 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, throw_away);
curl_easy_setopt(curl, CURLOPT_HEADER, 0L);
/* Switch on full protocol/debug output */
/* curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); */
#if 0
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
#endif
result = curl_easy_perform(curl);

View file

@ -158,8 +158,8 @@ static gboolean timer_cb(gpointer data)
struct GlobalInfo *g = (struct GlobalInfo *)data;
CURLMcode mresult;
mresult = curl_multi_socket_action(g->multi,
CURL_SOCKET_TIMEOUT, 0, &g->still_running);
mresult = curl_multi_socket_action(g->multi, CURL_SOCKET_TIMEOUT, 0,
&g->still_running);
mcode_or_die("timer_cb: curl_multi_socket_action", mresult);
check_multi_info(g);
return FALSE;
@ -360,7 +360,7 @@ static gboolean fifo_cb(GIOChannel *ch, GIOCondition condition, gpointer data)
}
else {
buf = g_malloc(BUF_SIZE + 1);
while(TRUE) {
for(;;) {
buf[BUF_SIZE] = '\0';
g_io_channel_read_chars(ch, buf, BUF_SIZE, &len, &err);
if(len) {

View file

@ -220,8 +220,8 @@ static void timer_cb(int fd, short kind, void *userp)
(void)fd;
(void)kind;
mresult = curl_multi_socket_action(g->multi,
CURL_SOCKET_TIMEOUT, 0, &g->still_running);
mresult = curl_multi_socket_action(g->multi, CURL_SOCKET_TIMEOUT, 0,
&g->still_running);
mcode_or_die("timer_cb: curl_multi_socket_action", mresult);
check_multi_info(g);
}

View file

@ -55,7 +55,7 @@ struct transfer {
int num;
};
static void dump(const char *text, int num, unsigned char *ptr,
static void dump(const char *text, int num, const unsigned char *ptr,
size_t size, char nohex)
{
size_t i;
@ -136,7 +136,7 @@ static int my_trace(CURL *curl, curl_infotype type,
return 0;
}
dump(text, num, (unsigned char *)data, size, 1);
dump(text, num, (const unsigned char *)data, size, 1);
return 0;
}

View file

@ -47,7 +47,8 @@
static FILE *out_download;
static void dump(const char *text, unsigned char *ptr, size_t size, char nohex)
static void dump(const char *text, const unsigned char *ptr,
size_t size, char nohex)
{
size_t i;
size_t c;
@ -126,7 +127,7 @@ static int my_trace(CURL *curl, curl_infotype type,
return 0;
}
dump(text, (unsigned char *)data, size, 1);
dump(text, (const unsigned char *)data, size, 1);
return 0;
}

View file

@ -73,7 +73,7 @@ static int my_gettimeofday(struct timeval *tp, void *tzp)
(void)tzp;
if(tp) {
/* Offset between 1601-01-01 and 1970-01-01 in 100 nanosec units */
#define WIN32_FT_OFFSET (116444736000000000)
#define WIN32_FT_OFFSET 116444736000000000
union {
CURL_TYPEOF_CURL_OFF_T ns100; /* time since 1 Jan 1601 in 100ns units */
FILETIME ft;
@ -191,7 +191,7 @@ static int my_trace(CURL *curl, curl_infotype type,
return 0;
}
dump(text, num, (unsigned char *)data, size, 1);
dump(text, num, (const unsigned char *)data, size, 1);
return 0;
}

View file

@ -30,9 +30,7 @@
#include <curl/curl.h>
#define TRUE 1
static void dump(const char *text, FILE *stream, const unsigned char *ptr,
static void dump(const char *text, const unsigned char *ptr,
size_t size, char nohex)
{
size_t i;
@ -44,20 +42,20 @@ static void dump(const char *text, FILE *stream, const unsigned char *ptr,
/* without the hex output, we can fit more on screen */
width = 0x40;
fprintf(stream, "%s, %10.10lu bytes (0x%8.8lx)\n",
fprintf(stderr, "%s, %10.10lu bytes (0x%8.8lx)\n",
text, (unsigned long)size, (unsigned long)size);
for(i = 0; i < size; i += width) {
fprintf(stream, "%4.4lx: ", (unsigned long)i);
fprintf(stderr, "%4.4lx: ", (unsigned long)i);
if(!nohex) {
/* hex not disabled, show it */
for(c = 0; c < width; c++)
if(i + c < size)
fprintf(stream, "%02x ", ptr[i + c]);
fprintf(stderr, "%02x ", ptr[i + c]);
else
fputs(" ", stream);
fputs(" ", stderr);
}
for(c = 0; (c < width) && (i + c < size); c++) {
@ -67,7 +65,7 @@ static void dump(const char *text, FILE *stream, const unsigned char *ptr,
i += (c + 2 - width);
break;
}
fprintf(stream, "%c",
fprintf(stderr, "%c",
(ptr[i + c] >= 0x20) && (ptr[i + c] < 0x80) ? ptr[i + c] : '.');
/* check again for 0D0A, to avoid an extra \n if it is at width */
if(nohex && (i + c + 2 < size) && ptr[i + c + 1] == 0x0D &&
@ -76,14 +74,12 @@ static void dump(const char *text, FILE *stream, const unsigned char *ptr,
break;
}
}
fputc('\n', stream); /* newline */
fputc('\n', stderr); /* newline */
}
fflush(stream);
}
static int my_trace(CURL *curl, curl_infotype type,
unsigned char *data, size_t size,
void *userp)
char *data, size_t size, void *userp)
{
const char *text;
@ -110,7 +106,7 @@ static int my_trace(CURL *curl, curl_infotype type,
return 0;
}
dump(text, stderr, data, size, TRUE);
dump(text, (const unsigned char *)data, size, 1);
return 0;
}

View file

@ -152,7 +152,9 @@ static void *create_thread(void *progress_bar)
gtk_widget_destroy(progress_bar);
/* [Un]Comment this out to kill the program rather than pushing close. */
/* gtk_main_quit(); */
#if 0
gtk_main_quit();
#endif
return NULL;
}

View file

@ -34,7 +34,6 @@
#define CURL_TELOPT_TTYPE 24 /* Terminal TYPE */
#define CURL_TELOPT_NAWS 31 /* Negotiate About Window Size */
#define CURL_TELOPT_XDISPLOC 35 /* X DISPlay LOCation */
#define CURL_TELOPT_NEW_ENVIRON 39 /* NEW ENVIRONment variables */
#define CURL_NEW_ENV_VAR 0
#define CURL_NEW_ENV_VALUE 1
@ -101,7 +100,8 @@ static const char * const telnetcmds[] = {
#define CURL_TELQUAL_INFO 2
#define CURL_TELQUAL_NAME 3
#define CURL_TELCMD_OK(x) (((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \
#define CURL_TELCMD_OK(x) \
(((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \
((unsigned int)(x) <= CURL_TELCMD_MAXIMUM))
#ifdef CURLVERBOSE

View file

@ -743,8 +743,7 @@ CURLcode Curl_async_getaddrinfo(struct Curl_easy *data, const char *hostname,
ares->ares_status = ARES_ENOTFOUND;
ares->result = CURLE_OK;
#if defined(CURLVERBOSE) && \
ARES_VERSION >= 0x011800 /* >= v1.24.0 */
#if defined(CURLVERBOSE) && ARES_VERSION >= 0x011800 /* >= v1.24.0 */
if(CURL_TRC_DNS_is_verbose(data)) {
char *csv = ares_get_servers_csv(ares->channel);
CURL_TRC_DNS(data, "asyn-ares: servers=%s", csv);
@ -759,8 +758,7 @@ CURLcode Curl_async_getaddrinfo(struct Curl_easy *data, const char *hostname,
int pf = PF_INET;
memset(&hints, 0, sizeof(hints));
#ifdef CURLRES_IPV6
if((ip_version != CURL_IPRESOLVE_V4) &&
Curl_ipv6works(data)) {
if((ip_version != CURL_IPRESOLVE_V4) && Curl_ipv6works(data)) {
/* The stack seems to be IPv6-enabled */
if(ip_version == CURL_IPRESOLVE_V6)
pf = PF_INET6;

View file

@ -226,8 +226,7 @@ static CURLcode proxy_h2_nw_out_writer(void *writer_ctx,
if(cf) {
struct Curl_easy *data = CF_DATA_CURRENT(cf);
CURLcode result;
result = Curl_conn_cf_send(cf->next, data, buf, buflen,
FALSE, pnwritten);
result = Curl_conn_cf_send(cf->next, data, buf, buflen, FALSE, pnwritten);
CURL_TRC_CF(data, cf, "[0] nw_out_writer(len=%zu) -> %d, %zu",
buflen, result, *pnwritten);
return result;

View file

@ -280,8 +280,7 @@
*/
/* Default define to enable threaded asynchronous DNS lookups. */
#if !defined(USE_SYNC_DNS) && !defined(USE_ARES) && \
!defined(USE_THREADS_WIN32)
#if !defined(USE_SYNC_DNS) && !defined(USE_ARES) && !defined(USE_THREADS_WIN32)
# define USE_THREADS_WIN32 1
#endif

View file

@ -401,8 +401,8 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
/* Add the connection to our shutdown list for non-blocking shutdown
* during multi processing. */
if(max_total > 0 && (max_total <=
(conns_in_pool + Curl_llist_count(&cshutdn->list)))) {
if(max_total > 0 &&
(max_total <= (conns_in_pool + Curl_llist_count(&cshutdn->list)))) {
CURL_TRC_M(data, "[SHUTDOWN] discarding oldest shutdown connection "
"due to connection limit of %zu", max_total);
cshutdn_destroy_oldest(cshutdn, data, NULL);

View file

@ -84,13 +84,10 @@
# define DES_set_key_unchecked wolfSSL_DES_set_key_unchecked
# define DES_ecb_encrypt wolfSSL_DES_ecb_encrypt
# define DESKEY(x) ((WOLFSSL_DES_key_schedule *)(x))
# if defined(LIBWOLFSSL_VERSION_HEX) && \
(LIBWOLFSSL_VERSION_HEX >= 0x05007006)
# if defined(LIBWOLFSSL_VERSION_HEX) && LIBWOLFSSL_VERSION_HEX >= 0x05007006
# define DES_ENCRYPT WC_DES_ENCRYPT
# define DES_DECRYPT WC_DES_DECRYPT
# endif
# else
# define DESKEY(x) &x
# endif

View file

@ -284,9 +284,9 @@ typedef unsigned int curl_bit;
*/
#ifdef USE_WINSOCK
#define SOCKERRNO ((int)WSAGetLastError())
#define SET_SOCKERRNO(x) (WSASetLastError((int)(x)))
#define SET_SOCKERRNO(x) WSASetLastError((int)(x))
#else
#define SOCKERRNO (errno)
#define SOCKERRNO errno
#define SET_SOCKERRNO(x) (errno = (x))
#endif

View file

@ -580,7 +580,7 @@ static void trc_apply_level_by_name(struct Curl_str *token, int lvl)
}
}
static void trc_apply_level_by_category(int category, int lvl)
static void trc_apply_level_by_category(unsigned int category, int lvl)
{
size_t i;

View file

@ -616,7 +616,9 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
if(!pollrc) {
/* timeout! */
ev->ms = 0;
/* curl_mfprintf(stderr, "call curl_multi_socket_action(TIMEOUT)\n"); */
#if 0
curl_mfprintf(stderr, "call curl_multi_socket_action(TIMEOUT)\n");
#endif
mresult = curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0,
&ev->running_handles);
}

View file

@ -866,6 +866,7 @@ static CURLcode imap_perform_append(struct Curl_easy *data,
/* Prepare the mime data if some. */
if(IS_MIME_POST(data)) {
curl_mimepart *postp = data->set.mimepostp;
/* Use the whole structure as data. */
postp->flags &= ~(unsigned int)MIME_BODY_ONLY;

View file

@ -86,14 +86,14 @@ static int MD4_Init(MD4_CTX *ctx)
return CC_MD4_Init(ctx);
}
static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
static void MD4_Update(MD4_CTX *ctx, const void *input, unsigned long len)
{
(void)CC_MD4_Update(ctx, data, (CC_LONG)size);
(void)CC_MD4_Update(ctx, input, (CC_LONG)len);
}
static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
static void MD4_Final(unsigned char *digest, MD4_CTX *ctx)
{
(void)CC_MD4_Final(result, ctx);
(void)CC_MD4_Final(digest, ctx);
}
#elif defined(USE_WIN32_CRYPTO)
@ -122,18 +122,18 @@ static int MD4_Init(MD4_CTX *ctx)
return 1;
}
static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
static void MD4_Update(MD4_CTX *ctx, const void *input, unsigned long len)
{
CryptHashData(ctx->hHash, (const BYTE *)data, (unsigned int)size, 0);
CryptHashData(ctx->hHash, (const BYTE *)input, (unsigned int)len, 0);
}
static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
static void MD4_Final(unsigned char *digest, MD4_CTX *ctx)
{
unsigned long length = 0;
CryptGetHashParam(ctx->hHash, HP_HASHVAL, NULL, &length, 0);
if(length == MD4_DIGEST_LENGTH)
CryptGetHashParam(ctx->hHash, HP_HASHVAL, result, &length, 0);
CryptGetHashParam(ctx->hHash, HP_HASHVAL, digest, &length, 0);
if(ctx->hHash)
CryptDestroyHash(ctx->hHash);
@ -152,14 +152,14 @@ static int MD4_Init(MD4_CTX *ctx)
return 1;
}
static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
static void MD4_Update(MD4_CTX *ctx, const void *input, unsigned long len)
{
md4_update(ctx, size, data);
md4_update(ctx, len, input);
}
static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
static void MD4_Final(unsigned char *digest, MD4_CTX *ctx)
{
md4_digest(ctx, MD4_DIGEST_SIZE, result);
md4_digest(ctx, MD4_DIGEST_SIZE, digest);
}
#else
@ -240,12 +240,12 @@ typedef struct md4_ctx MD4_CTX;
* the bit counters. There are no alignment requirements.
*/
static const void *my_md4_body(MD4_CTX *ctx,
const void *data, unsigned long size)
const void *input, unsigned long size)
{
const unsigned char *ptr;
uint32_t a, b, c, d;
ptr = (const unsigned char *)data;
ptr = (const unsigned char *)input;
a = ctx->a;
b = ctx->b;
@ -339,45 +339,46 @@ static int MD4_Init(MD4_CTX *ctx)
ctx->lo = 0;
ctx->hi = 0;
return 1;
}
static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
static void MD4_Update(MD4_CTX *ctx, const void *input, unsigned long len)
{
uint32_t saved_lo;
unsigned long used;
saved_lo = ctx->lo;
ctx->lo = (saved_lo + size) & 0x1fffffff;
ctx->lo = (saved_lo + len) & 0x1fffffff;
if(ctx->lo < saved_lo)
ctx->hi++;
ctx->hi += (uint32_t)size >> 29;
ctx->hi += (uint32_t)len >> 29;
used = saved_lo & 0x3f;
if(used) {
unsigned long available = 64 - used;
if(size < available) {
memcpy(&ctx->buffer[used], data, size);
if(len < available) {
memcpy(&ctx->buffer[used], input, len);
return;
}
memcpy(&ctx->buffer[used], data, available);
data = (const unsigned char *)data + available;
size -= available;
memcpy(&ctx->buffer[used], input, available);
input = (const unsigned char *)input + available;
len -= available;
my_md4_body(ctx, ctx->buffer, 64);
}
if(size >= 64) {
data = my_md4_body(ctx, data, size & ~(unsigned long)0x3f);
size &= 0x3f;
if(len >= 64) {
input = my_md4_body(ctx, input, len & ~(unsigned long)0x3f);
len &= 0x3f;
}
memcpy(ctx->buffer, data, size);
memcpy(ctx->buffer, input, len);
}
static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
static void MD4_Final(unsigned char *digest, MD4_CTX *ctx)
{
unsigned long used, available;
@ -408,30 +409,30 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
my_md4_body(ctx, ctx->buffer, 64);
result[0] = curlx_ultouc((ctx->a) & 0xff);
result[1] = curlx_ultouc((ctx->a >> 8) & 0xff);
result[2] = curlx_ultouc((ctx->a >> 16) & 0xff);
result[3] = curlx_ultouc(ctx->a >> 24);
result[4] = curlx_ultouc((ctx->b) & 0xff);
result[5] = curlx_ultouc((ctx->b >> 8) & 0xff);
result[6] = curlx_ultouc((ctx->b >> 16) & 0xff);
result[7] = curlx_ultouc(ctx->b >> 24);
result[8] = curlx_ultouc((ctx->c) & 0xff);
result[9] = curlx_ultouc((ctx->c >> 8) & 0xff);
result[10] = curlx_ultouc((ctx->c >> 16) & 0xff);
result[11] = curlx_ultouc(ctx->c >> 24);
result[12] = curlx_ultouc((ctx->d) & 0xff);
result[13] = curlx_ultouc((ctx->d >> 8) & 0xff);
result[14] = curlx_ultouc((ctx->d >> 16) & 0xff);
result[15] = curlx_ultouc(ctx->d >> 24);
digest[0] = curlx_ultouc((ctx->a) & 0xff);
digest[1] = curlx_ultouc((ctx->a >> 8) & 0xff);
digest[2] = curlx_ultouc((ctx->a >> 16) & 0xff);
digest[3] = curlx_ultouc(ctx->a >> 24);
digest[4] = curlx_ultouc((ctx->b) & 0xff);
digest[5] = curlx_ultouc((ctx->b >> 8) & 0xff);
digest[6] = curlx_ultouc((ctx->b >> 16) & 0xff);
digest[7] = curlx_ultouc(ctx->b >> 24);
digest[8] = curlx_ultouc((ctx->c) & 0xff);
digest[9] = curlx_ultouc((ctx->c >> 8) & 0xff);
digest[10] = curlx_ultouc((ctx->c >> 16) & 0xff);
digest[11] = curlx_ultouc(ctx->c >> 24);
digest[12] = curlx_ultouc((ctx->d) & 0xff);
digest[13] = curlx_ultouc((ctx->d >> 8) & 0xff);
digest[14] = curlx_ultouc((ctx->d >> 16) & 0xff);
digest[15] = curlx_ultouc(ctx->d >> 24);
memset(ctx, 0, sizeof(*ctx));
}
#endif /* CRYPTO LIBS */
CURLcode Curl_md4it(unsigned char *output, const unsigned char *input,
const size_t len)
CURLcode Curl_md4it(unsigned char *output,
const unsigned char *input, const size_t len)
{
MD4_CTX ctx;

View file

@ -87,10 +87,9 @@ static CURLcode my_md5_init(void *ctx)
}
static void my_md5_update(void *ctx,
const unsigned char *input,
unsigned int inputLen)
const unsigned char *input, unsigned int len)
{
md5_update(ctx, inputLen, input);
md5_update(ctx, len, input);
}
static void my_md5_final(unsigned char *digest, void *ctx)
@ -112,8 +111,7 @@ static CURLcode my_md5_init(void *ctx)
}
static void my_md5_update(void *ctx,
const unsigned char *input,
unsigned int len)
const unsigned char *input, unsigned int len)
{
(void)MD5_Update(ctx, input, len);
}
@ -136,8 +134,7 @@ static CURLcode my_md5_init(void *ctx)
}
static void my_md5_update(void *ctx,
const unsigned char *input,
unsigned int len)
const unsigned char *input, unsigned int len)
{
(void)wolfSSL_MD5_Update(ctx, input, len);
}
@ -160,10 +157,9 @@ static CURLcode my_md5_init(void *ctx)
}
static void my_md5_update(void *ctx,
const unsigned char *data,
unsigned int length)
const unsigned char *input, unsigned int len)
{
(void)psa_hash_update(ctx, data, length);
(void)psa_hash_update(ctx, input, len);
}
static void my_md5_final(unsigned char *digest, void *ctx)
@ -191,10 +187,9 @@ static CURLcode my_md5_init(void *ctx)
}
static void my_md5_update(void *ctx,
const unsigned char *input,
unsigned int inputLen)
const unsigned char *input, unsigned int len)
{
CC_MD5_Update(ctx, input, inputLen);
CC_MD5_Update(ctx, input, len);
}
static void my_md5_final(unsigned char *digest, void *ctx)
@ -227,11 +222,10 @@ static CURLcode my_md5_init(void *in)
}
static void my_md5_update(void *in,
const unsigned char *input,
unsigned int inputLen)
const unsigned char *input, unsigned int len)
{
my_md5_ctx *ctx = in;
CryptHashData(ctx->hHash, (const BYTE *)input, inputLen, 0);
CryptHashData(ctx->hHash, (const BYTE *)input, len, 0);
}
static void my_md5_final(unsigned char *digest, void *in)
@ -452,44 +446,44 @@ static CURLcode my_md5_init(void *in)
return CURLE_OK;
}
static void my_md5_update(void *in, const unsigned char *data,
unsigned int size)
static void my_md5_update(void *in,
const unsigned char *input, unsigned int len)
{
uint32_t saved_lo;
unsigned int used;
my_md5_ctx *ctx = (my_md5_ctx *)in;
saved_lo = ctx->lo;
ctx->lo = (saved_lo + size) & 0x1fffffff;
ctx->lo = (saved_lo + len) & 0x1fffffff;
if(ctx->lo < saved_lo)
ctx->hi++;
ctx->hi += (uint32_t)size >> 29;
ctx->hi += (uint32_t)len >> 29;
used = saved_lo & 0x3f;
if(used) {
unsigned int available = 64 - used;
if(size < available) {
memcpy(&ctx->buffer[used], data, size);
if(len < available) {
memcpy(&ctx->buffer[used], input, len);
return;
}
memcpy(&ctx->buffer[used], data, available);
data = (const unsigned char *)data + available;
size -= available;
memcpy(&ctx->buffer[used], input, available);
input = (const unsigned char *)input + available;
len -= available;
my_md5_body(ctx, ctx->buffer, 64);
}
if(size >= 64) {
data = my_md5_body(ctx, data, size & ~(unsigned long)0x3f);
size &= 0x3f;
if(len >= 64) {
input = my_md5_body(ctx, input, len & ~(unsigned long)0x3f);
len &= 0x3f;
}
memcpy(ctx->buffer, data, size);
memcpy(ctx->buffer, input, len);
}
static void my_md5_final(unsigned char *result, void *in)
static void my_md5_final(unsigned char *digest, void *in)
{
unsigned int used, available;
my_md5_ctx *ctx = (my_md5_ctx *)in;
@ -521,22 +515,22 @@ static void my_md5_final(unsigned char *result, void *in)
my_md5_body(ctx, ctx->buffer, 64);
result[0] = curlx_ultouc((ctx->a) & 0xff);
result[1] = curlx_ultouc((ctx->a >> 8) & 0xff);
result[2] = curlx_ultouc((ctx->a >> 16) & 0xff);
result[3] = curlx_ultouc(ctx->a >> 24);
result[4] = curlx_ultouc((ctx->b) & 0xff);
result[5] = curlx_ultouc((ctx->b >> 8) & 0xff);
result[6] = curlx_ultouc((ctx->b >> 16) & 0xff);
result[7] = curlx_ultouc(ctx->b >> 24);
result[8] = curlx_ultouc((ctx->c) & 0xff);
result[9] = curlx_ultouc((ctx->c >> 8) & 0xff);
result[10] = curlx_ultouc((ctx->c >> 16) & 0xff);
result[11] = curlx_ultouc(ctx->c >> 24);
result[12] = curlx_ultouc((ctx->d) & 0xff);
result[13] = curlx_ultouc((ctx->d >> 8) & 0xff);
result[14] = curlx_ultouc((ctx->d >> 16) & 0xff);
result[15] = curlx_ultouc(ctx->d >> 24);
digest[0] = curlx_ultouc((ctx->a) & 0xff);
digest[1] = curlx_ultouc((ctx->a >> 8) & 0xff);
digest[2] = curlx_ultouc((ctx->a >> 16) & 0xff);
digest[3] = curlx_ultouc(ctx->a >> 24);
digest[4] = curlx_ultouc((ctx->b) & 0xff);
digest[5] = curlx_ultouc((ctx->b >> 8) & 0xff);
digest[6] = curlx_ultouc((ctx->b >> 16) & 0xff);
digest[7] = curlx_ultouc(ctx->b >> 24);
digest[8] = curlx_ultouc((ctx->c) & 0xff);
digest[9] = curlx_ultouc((ctx->c >> 8) & 0xff);
digest[10] = curlx_ultouc((ctx->c >> 16) & 0xff);
digest[11] = curlx_ultouc(ctx->c >> 24);
digest[12] = curlx_ultouc((ctx->d) & 0xff);
digest[13] = curlx_ultouc((ctx->d >> 8) & 0xff);
digest[14] = curlx_ultouc((ctx->d >> 16) & 0xff);
digest[15] = curlx_ultouc(ctx->d >> 24);
memset(ctx, 0, sizeof(*ctx));
}
@ -564,8 +558,8 @@ const struct MD5_params Curl_DIGEST_MD5 = {
* @unittest: 1601
* Returns CURLE_OK on success.
*/
CURLcode Curl_md5it(unsigned char *outbuffer, const unsigned char *input,
const size_t len)
CURLcode Curl_md5it(unsigned char *output,
const unsigned char *input, const size_t len)
{
CURLcode result;
my_md5_ctx ctx;
@ -573,7 +567,7 @@ CURLcode Curl_md5it(unsigned char *outbuffer, const unsigned char *input,
result = my_md5_init(&ctx);
if(!result) {
my_md5_update(&ctx, input, curlx_uztoui(len));
my_md5_final(outbuffer, &ctx);
my_md5_final(output, &ctx);
}
return result;
}
@ -607,10 +601,9 @@ struct MD5_context *Curl_MD5_init(const struct MD5_params *md5params)
}
CURLcode Curl_MD5_update(struct MD5_context *context,
const unsigned char *data,
unsigned int len)
const unsigned char *input, unsigned int len)
{
(*context->md5_hash->md5_update_func)(context->md5_hashctx, data, len);
(*context->md5_hash->md5_update_func)(context->md5_hashctx, input, len);
return CURLE_OK;
}

View file

@ -71,7 +71,6 @@
* just as under Linux (e.g. <sys/socket.h>) and the Winsock headers should
* never be included when __CYGWIN__ is defined.
*/
#ifdef _WIN32
# if defined(UNICODE) && !defined(_UNICODE)
# error "UNICODE is defined but _UNICODE is not defined"
@ -89,7 +88,6 @@
* those symbols to compare against, and even those that do may be missing
* newer symbols.
*/
#ifndef _WIN32_WINNT_VISTA
#define _WIN32_WINNT_VISTA 0x0600 /* Windows Vista */
#endif

View file

@ -849,9 +849,10 @@ static CURLcode smtp_perform_command(struct Curl_easy *data,
/* Establish whether we should report SMTPUTF8 to the server for this
mailbox as per RFC-6531 sect. 3.1 point 6 */
utf8 = (smtpc->utf8_supported) &&
((host.encalloc) || (!Curl_is_ASCII_name(address)) ||
(!Curl_is_ASCII_name(host.name)));
utf8 = smtpc->utf8_supported &&
(host.encalloc ||
!Curl_is_ASCII_name(address) ||
!Curl_is_ASCII_name(host.name));
/* Send the VRFY command (Note: The hostname part may be absent when the
host is a local system) */
@ -924,9 +925,10 @@ static CURLcode smtp_perform_mail(struct Curl_easy *data,
/* Establish whether we should report SMTPUTF8 to the server for this
mailbox as per RFC-6531 sect. 3.1 point 4 and sect. 3.4 */
utf8 = (smtpc->utf8_supported) &&
((host.encalloc) || (!Curl_is_ASCII_name(address)) ||
(!Curl_is_ASCII_name(host.name)));
utf8 = smtpc->utf8_supported &&
(host.encalloc ||
!Curl_is_ASCII_name(address) ||
!Curl_is_ASCII_name(host.name));
if(host.name) {
from = curl_maprintf("<%s@%s>%s", address, host.name, suffix);
@ -965,9 +967,10 @@ static CURLcode smtp_perform_mail(struct Curl_easy *data,
/* Establish whether we should report SMTPUTF8 to the server for this
mailbox as per RFC-6531 sect. 3.1 point 4 and sect. 3.4 */
if((!utf8) && (smtpc->utf8_supported) &&
((host.encalloc) || (!Curl_is_ASCII_name(address)) ||
(!Curl_is_ASCII_name(host.name))))
if(!utf8 && smtpc->utf8_supported &&
(host.encalloc ||
!Curl_is_ASCII_name(address) ||
!Curl_is_ASCII_name(host.name)))
utf8 = TRUE;
if(host.name) {

View file

@ -254,8 +254,9 @@ static CURLcode sendrecv_dl(struct Curl_easy *data,
if(bytestoread && Curl_rlimit_active(&data->progress.dl.rlimit)) {
curl_off_t dl_avail = Curl_rlimit_avail(&data->progress.dl.rlimit,
Curl_pgrs_now(data));
/* DEBUGF(infof(data, "dl_rlimit, available=%" FMT_OFF_T, dl_avail));
*/
#if 0
DEBUGF(infof(data, "dl_rlimit, available=%" FMT_OFF_T, dl_avail));
#endif
/* In case of rate limited downloads: if this loop already got
* data and less than 16k is left in the limit, break out.
* We want to stutter a bit to keep in the limit, but too small

View file

@ -752,8 +752,8 @@ static bool ssh_config_matches(struct connectdata *one,
sshc1 = Curl_conn_meta_get(one, CURL_META_SSH_CONN);
sshc2 = Curl_conn_meta_get(two, CURL_META_SSH_CONN);
return (sshc1 && sshc2 && Curl_safecmp(sshc1->rsa, sshc2->rsa) &&
Curl_safecmp(sshc1->rsa_pub, sshc2->rsa_pub));
return sshc1 && sshc2 && Curl_safecmp(sshc1->rsa, sshc2->rsa) &&
Curl_safecmp(sshc1->rsa_pub, sshc2->rsa_pub);
}
#endif
@ -1081,9 +1081,9 @@ static bool url_match_destination(struct connectdata *conn,
}
/* We are in an IMAPS vs IMAP like case. We expect `conn` to have SSL */
if(!Curl_conn_is_ssl(conn, FIRSTSOCKET)) {
DEBUGF(infof(m->data,
"Connection #%" FMT_OFF_T " has compatible protocol family, "
"but no SSL, no match", conn->connection_id));
DEBUGF(infof(m->data, "Connection #%" FMT_OFF_T
" has compatible protocol family, but no SSL, no match",
conn->connection_id));
return FALSE;
}
}
@ -1109,8 +1109,7 @@ static bool url_match_ssl_config(struct connectdata *conn,
/* If talking TLS, conn needs to use the same SSL options. */
if((m->needle->scheme->flags & PROTOPT_SSL) &&
!Curl_ssl_conn_config_match(m->data, conn, FALSE)) {
DEBUGF(infof(m->data,
"Connection #%" FMT_OFF_T
DEBUGF(infof(m->data, "Connection #%" FMT_OFF_T
" has different SSL parameters, cannot reuse",
conn->connection_id));
return FALSE;

View file

@ -1607,7 +1607,6 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf,
0, pnwritten);
if(result)
goto out;
if(!stream->h1.done) {
/* need more data */
goto out;

View file

@ -51,7 +51,7 @@
#include "../vtls/vtls.h"
/* HTTP/3 error values defined in RFC 9114, ch. 8.1 */
#define CURL_H3_NO_ERROR (0x0100)
#define CURL_H3_NO_ERROR 0x0100
#define QUIC_MAX_STREAMS (100)

View file

@ -58,18 +58,18 @@
|N|V|V|V| |
| |1|2|3| |
*/
#define WSBIT_FIN (0x80)
#define WSBIT_RSV1 (0x40)
#define WSBIT_RSV2 (0x20)
#define WSBIT_RSV3 (0x10)
#define WSBIT_FIN 0x80
#define WSBIT_RSV1 0x40
#define WSBIT_RSV2 0x20
#define WSBIT_RSV3 0x10
#define WSBIT_RSV_MASK (WSBIT_RSV1 | WSBIT_RSV2 | WSBIT_RSV3)
#define WSBIT_OPCODE_CONT (0x0)
#define WSBIT_OPCODE_TEXT (0x1)
#define WSBIT_OPCODE_BIN (0x2)
#define WSBIT_OPCODE_CLOSE (0x8)
#define WSBIT_OPCODE_PING (0x9)
#define WSBIT_OPCODE_PONG (0xa)
#define WSBIT_OPCODE_MASK (0xf)
#define WSBIT_OPCODE_CONT 0x0
#define WSBIT_OPCODE_TEXT 0x1
#define WSBIT_OPCODE_BIN 0x2
#define WSBIT_OPCODE_CLOSE 0x8
#define WSBIT_OPCODE_PING 0x9
#define WSBIT_OPCODE_PONG 0xa
#define WSBIT_OPCODE_MASK 0xf
#define WSBIT_MASK 0x80
@ -387,7 +387,9 @@ static CURLcode ws_dec_read_head(struct ws_decoder *dec,
}
dec->head_len = 1;
/* ws_dec_info(dec, data, "seeing opcode"); */
#if 0
ws_dec_info(dec, data, "seeing opcode");
#endif
continue;
}
else if(dec->head_len == 1) {
@ -439,7 +441,9 @@ static CURLcode ws_dec_read_head(struct ws_decoder *dec,
Curl_bufq_skip(inraw, 1);
++dec->head_len;
if(dec->head_len < dec->head_total) {
/* ws_dec_info(dec, data, "decoding head"); */
#if 0
ws_dec_info(dec, data, "decoding head");
#endif
continue;
}
}

View file

@ -277,7 +277,9 @@ static void set_features(void)
/* Commented here to prevent future bugs: A program or user should */
/* never ever enable DECC$POSIX_STYLE_UID. */
/* It will probably break all code that accesses UIDs */
/* do_not_set_default("DECC$POSIX_STYLE_UID", TRUE); */
#if 0
do_not_set_default("DECC$POSIX_STYLE_UID", TRUE);
#endif
}
/* Some boilerplate to force this to be a proper LIB$INITIALIZE section */

View file

@ -39,7 +39,6 @@
* get_terminal_columns() returns the number of columns in the current
* terminal. It will return 79 on failure. Also, the number can be big.
*/
unsigned int get_terminal_columns(void)
{
unsigned int width = 0;

View file

@ -46,7 +46,7 @@
# ifdef S_IFCHR
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
# else
# define S_ISCHR(m) (0) /* cannot tell if file is a device */
# define S_ISCHR(m) 0 /* cannot tell if file is a device */
# endif
#endif

View file

@ -2880,7 +2880,7 @@ static ParameterError opt_string(struct OperationConfig *config,
/* detect e2 80 80 - e2 80 ff */
static bool has_leading_unicode(const unsigned char *arg)
{
return ((arg[0] == 0xe2) && (arg[1] == 0x80) && (arg[2] & 0x80));
return (arg[0] == 0xe2) && (arg[1] == 0x80) && (arg[2] & 0x80);
}
/* the longest command line option, excluding the leading -- */

View file

@ -33,7 +33,7 @@
static bool has_trailing_slash(const char *input)
{
size_t len = strlen(input);
return (len && input[len - 1] == '/');
return len && input[len - 1] == '/';
}
static char *ipfs_gateway(void)

View file

@ -707,6 +707,7 @@ CURLcode tool_setopt_str(CURL *curl, struct OperationConfig *config,
/* return TRUE if the error code is "lethal" */
bool setopt_bad(CURLcode result)
{
return (result && (result != CURLE_NOT_BUILT_IN) &&
(result != CURLE_UNKNOWN_OPTION));
return result &&
(result != CURLE_NOT_BUILT_IN) &&
(result != CURLE_UNKNOWN_OPTION);
}

View file

@ -38,7 +38,7 @@ int is_vms_shell(void);
void vms_special_exit(int code, int vms_show);
#undef exit
#define exit(__code) vms_special_exit((__code), (0))
#define exit(__code) vms_special_exit(__code, 0)
#define VMS_STS(c, f, e, s) \
(((c & 0xF) << 28) | ((f & 0xFFF) << 16) | ((e & 0x1FFF) < 3) | (s & 7))

View file

@ -404,7 +404,9 @@ static CURLcode test_cli_hx_download(const char *URL)
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
/* curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT); */
#if 0
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
#endif
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_PSL);
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_HSTS);

View file

@ -65,7 +65,9 @@ static int progress_callback(void *clientp,
{
CURL *curl = (CURL *)clientp;
curl_easy_pause(curl, CURLPAUSE_CONT);
/* curl_easy_pause(curl, CURLPAUSE_RECV_CONT); */
#if 0
curl_easy_pause(curl, CURLPAUSE_RECV_CONT);
#endif
}
#endif
return 0;

View file

@ -43,10 +43,10 @@ static size_t WriteHeader(char *ptr, size_t size, size_t nmemb, void *stream)
static CURLcode test_lib1509(const char *URL)
{
long headerSize;
CURLcode code;
CURL *curl = NULL;
CURLcode code;
CURLcode result = CURLE_OK;
long headerSize;
global_init(CURL_GLOBAL_ALL);

View file

@ -95,8 +95,10 @@ static CURLcode test_lib1517(const char *URL)
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
#if 0
/* detect HTTP error codes >= 400 */
/* test_setopt(curl, CURLOPT_FAILONERROR, 1L); */
test_setopt(curl, CURLOPT_FAILONERROR, 1L);
#endif
/* Perform the request, result will get the return code */
result = curl_easy_perform(curl);

View file

@ -42,8 +42,8 @@ static size_t header(char *ptr, size_t size, size_t nmemb, void *stream)
static CURLcode test_lib1556(const char *URL)
{
CURLcode code;
CURL *curl = NULL;
CURLcode code;
CURLcode result = CURLE_OK;
struct headerinfo info = { 0 };

View file

@ -29,7 +29,7 @@
#error "this test requires FD_SETSIZE"
#endif
#define T518_SAFETY_MARGIN (16)
#define T518_SAFETY_MARGIN 16
#define NUM_OPEN (FD_SETSIZE + 10)
#define NUM_NEEDED (NUM_OPEN + T518_SAFETY_MARGIN)

View file

@ -29,7 +29,7 @@
#error "this test requires FD_SETSIZE"
#endif
#define T537_SAFETY_MARGIN (11)
#define T537_SAFETY_MARGIN 11
#if defined(_WIN32) || defined(MSDOS)
#define DEV_NULL "NUL"

View file

@ -69,14 +69,18 @@ static size_t rtp_write(char *data, size_t size, size_t nmemb, void *stream)
if(message_size - i > RTP_DATA_SIZE) {
if(memcmp(RTP_DATA, data + i, RTP_DATA_SIZE) != 0) {
curl_mprintf("RTP PAYLOAD CORRUPTED [%s]\n", data + i);
/* return failure; */
#if 0
return failure;
#endif
}
}
else {
if(memcmp(RTP_DATA, data + i, message_size - i) != 0) {
curl_mprintf("RTP PAYLOAD END CORRUPTED (%d), [%s]\n",
message_size - i, data + i);
/* return failure; */
#if 0
return failure;
#endif
}
}
}

View file

@ -632,7 +632,9 @@ static int test_dnsd(int argc, char **argv)
clear_advisor_read_lock(loglockfile);
}
/* logmsg("end of one transfer"); */
#if 0
logmsg("end of one transfer");
#endif
}
dnsd_cleanup: