tidy-up: miscellaneous

Closes #20851
This commit is contained in:
Viktor Szakats 2026-02-26 03:13:56 +01:00
parent cbb5544c45
commit ccba492024
No known key found for this signature in database
36 changed files with 114 additions and 118 deletions

View file

@ -45,4 +45,4 @@ Checks:
CheckOptions:
misc-header-include-cycle.IgnoredFilesList: 'curl/curl.h'
HeaderFilterRegex: '.*'
HeaderFilterRegex: '.*' # Default in v22.1.0+

View file

@ -2356,6 +2356,7 @@ if(NOT CURL_DISABLE_INSTALL)
# TARGETS_EXPORT_NAME
# CURL_SUPPORTED_FEATURES_LIST
# CURL_SUPPORTED_PROTOCOLS_LIST
# CURL_USE_PKGCONFIG
# HAVE_BROTLI
# HAVE_GSSAPI
# HAVE_LIBIDN2

View file

@ -49,9 +49,9 @@ if [ -n "${CMAKE_GENERATOR:-}" ]; then
# Install custom cmake version
if [ -n "${CMAKE_VERSION:-}" ]; then
cmake_ver=$(printf '%02d%02d' \
cmake_ver="$(printf '%02d%02d' \
"$(echo "${CMAKE_VERSION}" | cut -f1 -d.)" \
"$(echo "${CMAKE_VERSION}" | cut -f2 -d.)")
"$(echo "${CMAKE_VERSION}" | cut -f2 -d.)")"
if [ "${cmake_ver}" -ge '0320' ]; then
fn="cmake-${CMAKE_VERSION}-windows-x86_64"
else

View file

@ -485,7 +485,7 @@ Select from these:
--with-amissl
--with-gnutls
--with-mbedtls
--with-openssl (also works for BoringSSL and LibreSSL)
--with-openssl (also works for AWS-LC, BoringSSL and LibreSSL)
--with-rustls
--with-schannel
--with-wolfssl
@ -2047,8 +2047,8 @@ if test "$USE_WIN32_CRYPTO" = "1" || test "$SCHANNEL_ENABLED" = "1"; then
LIBS="-ladvapi32 -lcrypt32 $LIBS"
fi
dnl link bcrypt for BCryptGenRandom() (used when building for Vista or newer)
if test "$curl_cv_native_windows" = "yes"; then
dnl for BCryptGenRandom()
LIBS="-lbcrypt $LIBS"
fi

View file

@ -47,9 +47,9 @@ Example: to add a `struct foobar` to a linked list. Add a node struct within
it:
struct foobar {
char *random;
struct Curl_llist_node storage; /* can be anywhere in the struct */
char *data;
char *random;
struct Curl_llist_node storage; /* can be anywhere in the struct */
char *data;
};
struct Curl_llist barlist; /* the list for foobar entries */
@ -77,18 +77,18 @@ To iterate over a list: first get the head entry and then iterate over the
nodes as long there is a next. Each node has an *element* associated with it,
the custom pointer you stored there. Usually a struct pointer or similar.
struct Curl_llist_node *iter;
struct Curl_llist_node *iter;
/* get the first entry of the 'barlist' */
iter = Curl_llist_head(&barlist);
/* get the first entry of the 'barlist' */
iter = Curl_llist_head(&barlist);
while(iter) {
/* extract the element pointer from the node */
struct foobar *elem = Curl_node_elem(iter);
while(iter) {
/* extract the element pointer from the node */
struct foobar *elem = Curl_node_elem(iter);
/* advance to the next node in the list */
iter = Curl_node_next(iter);
}
/* advance to the next node in the list */
iter = Curl_node_next(iter);
}
# Function overview

View file

@ -20,7 +20,7 @@ curl_easy_getinfo - extract information from a curl handle
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );
CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
~~~
# DESCRIPTION

View file

@ -81,12 +81,12 @@ the time it is called.
~~~c
struct curl_header {
char *name;
char *value;
size_t amount;
size_t index;
unsigned int origin;
void *anchor;
char *name;
char *value;
size_t amount;
size_t index;
unsigned int origin;
void *anchor;
};
~~~

View file

@ -21,7 +21,7 @@ curl_easy_pause - pause and unpause a connection
~~~c
#include <curl/curl.h>
CURLcode curl_easy_pause(CURL *handle, int bitmask );
CURLcode curl_easy_pause(CURL *handle, int bitmask);
~~~
# DESCRIPTION

View file

@ -51,10 +51,10 @@ static int push_cb(CURL *parent,
int i = 0;
char *field;
do {
field = curl_pushheader_bynum(headers, i);
if(field)
fprintf(stderr, "Push header: %s\n", field);
i++;
field = curl_pushheader_bynum(headers, i);
if(field)
fprintf(stderr, "Push header: %s\n", field);
i++;
} while(field);
return CURL_PUSH_OK; /* permission granted */
}

View file

@ -92,7 +92,7 @@ NULL
#include <stdio.h>
struct callback_data {
FILE *output;
FILE *output;
};
static long file_is_coming(struct curl_fileinfo *finfo,

View file

@ -42,7 +42,7 @@ NULL
#include <stdio.h>
struct callback_data {
FILE *output;
FILE *output;
};
static long file_is_coming(struct curl_fileinfo *finfo,

View file

@ -50,7 +50,7 @@ NULL
#include <stdio.h>
struct callback_data {
FILE *output;
FILE *output;
};
static long file_is_downloaded(void *ptr)

View file

@ -80,7 +80,7 @@ signal that it already is connected.
The equivalent of this:
~~~c
return socket(addr->family, addr->socktype, addr->protocol);
return socket(addr->family, addr->socktype, addr->protocol);
~~~
# %PROTOCOLS%

View file

@ -64,7 +64,7 @@ GitHub Actions runs the following tests:
- Tests with a variety of different compilation options, OSes, CPUs.
- Fuzz tests ([see the curl-fuzzer repo for more
info](https://github.com/curl/curl-fuzzer)).
- Static analysis and sanitizers: clang-tidy, scan-build, address sanitizer,
- Static analysis and sanitizers: clang-tidy, address sanitizer,
memory sanitizer, thread sanitizer, CodeQL, valgrind, torture tests.
These are each configured in different files in `.github/workflows`.

View file

@ -1281,7 +1281,7 @@ static CURLcode cf_tcp_connect(struct Curl_cfilter *cf,
set_local_ip(cf, data);
CURL_TRC_CF(data, cf, "local address %s port %d...",
ctx->ip.local_ip, ctx->ip.local_port);
if(-1 == rc) {
if(rc == -1) {
result = socket_connect_result(data, ctx->ip.remote_ip, error);
goto out;
}
@ -1801,7 +1801,7 @@ static CURLcode cf_udp_setup_quic(struct Curl_cfilter *cf,
NOLINTNEXTLINE(clang-analyzer-unix.StdCLibraryFunctions) */
rc = connect(ctx->sock, &ctx->addr.curl_sa_addr,
(curl_socklen_t)ctx->addr.addrlen);
if(-1 == rc) {
if(rc == -1) {
return socket_connect_result(data, ctx->ip.remote_ip, SOCKERRNO);
}
ctx->sock_connected = TRUE;

View file

@ -396,7 +396,7 @@ static CURLcode storecookie(struct Cookie *co, struct Curl_str *cp,
/* No path was given in the header line, set the default */
const char *endslash = strrchr(path, '/');
if(endslash)
plen = (endslash - path + 1); /* include end slash */
plen = endslash - path + 1; /* include end slash */
else
plen = strlen(path);
}

View file

@ -226,7 +226,7 @@ bool curlx_verify_windows_version(const unsigned int majorVersion,
matched = !pRtlVerifyVersionInfo(&osver, dwTypeMask, cm);
else
matched = !!VerifyVersionInfoW((OSVERSIONINFOEXW *)&osver,
dwTypeMask, cm);
dwTypeMask, cm);
}
#endif

View file

@ -29,14 +29,14 @@
typedef enum {
DOH_OK,
DOH_DNS_BAD_LABEL, /* 1 */
DOH_DNS_OUT_OF_RANGE, /* 2 */
DOH_DNS_LABEL_LOOP, /* 3 */
DOH_TOO_SMALL_BUFFER, /* 4 */
DOH_OUT_OF_MEM, /* 5 */
DOH_DNS_RDATA_LEN, /* 6 */
DOH_DNS_MALFORMAT, /* 7 */
DOH_DNS_BAD_RCODE, /* 8 - no such name */
DOH_DNS_BAD_LABEL, /* 1 */
DOH_DNS_OUT_OF_RANGE, /* 2 */
DOH_DNS_LABEL_LOOP, /* 3 */
DOH_TOO_SMALL_BUFFER, /* 4 */
DOH_OUT_OF_MEM, /* 5 */
DOH_DNS_RDATA_LEN, /* 6 */
DOH_DNS_MALFORMAT, /* 7 */
DOH_DNS_BAD_RCODE, /* 8 - no such name */
DOH_DNS_UNEXPECTED_TYPE, /* 9 */
DOH_DNS_UNEXPECTED_CLASS, /* 10 */
DOH_NO_CONTENT, /* 11 */

View file

@ -203,7 +203,7 @@ typedef struct md4_ctx MD4_CTX;
* The MD4 transformation for all three rounds.
*/
#define MD4_STEP(f, a, b, c, d, x, s) \
(a) += f((b), (c), (d)) + (x); \
(a) += f(b, c, d) + (x); \
(a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s))));
/*

View file

@ -283,7 +283,7 @@ typedef struct md5_ctx my_md5_ctx;
* The MD5 transformation for all four rounds.
*/
#define MD5_STEP(f, a, b, c, d, x, t, s) \
(a) += f((b), (c), (d)) + (x) + (t); \
(a) += f(b, c, d) + (x) + (t); \
(a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
(a) += (b);

View file

@ -481,12 +481,12 @@ static int parsedate(const char *date, time_t *output)
part++;
}
if(-1 == secnum)
if(secnum == -1)
secnum = minnum = hournum = 0; /* no time, make it zero */
if((-1 == mdaynum) ||
(-1 == monnum) ||
(-1 == yearnum))
if((mdaynum == -1) ||
(monnum == -1) ||
(yearnum == -1))
/* lacks vital info, fail */
return PARSEDATE_FAIL;

View file

@ -275,7 +275,7 @@ static const unsigned long K[64] = {
#define Sha256_Ch(x, y, z) (z ^ (x & (y ^ z)))
#define Sha256_Maj(x, y, z) (((x | y) & z) | (x & y))
#define Sha256_S(x, n) RORc((x), (n))
#define Sha256_S(x, n) RORc(x, n)
#define Sha256_R(x, n) (((x) & 0xFFFFFFFFUL) >> (n))
#define Sigma0(x) (Sha256_S(x, 2) ^ Sha256_S(x, 13) ^ Sha256_S(x, 22))
@ -416,7 +416,7 @@ static void my_sha256_final(unsigned char *out, void *ctx)
*/
if(md->curlen > 56) {
while(md->curlen < 64) {
md->buf[md->curlen++] = (unsigned char)0;
md->buf[md->curlen++] = 0;
}
sha256_compress(md, md->buf);
md->curlen = 0;
@ -424,7 +424,7 @@ static void my_sha256_final(unsigned char *out, void *ctx)
/* Pad up to 56 bytes of zeroes */
while(md->curlen < 56) {
md->buf[md->curlen++] = (unsigned char)0;
md->buf[md->curlen++] = 0;
}
/* Store length */

View file

@ -74,7 +74,7 @@
#define CURLPROTO_WSS 0L
#endif
#define CURLPROTO_MQTTS (1LL << 32)
#define CURLPROTO_MQTTS (1LL << 32)
#define CURLPROTO_64ALL ((uint64_t)0xffffffffffffffff)
@ -87,7 +87,7 @@ typedef curl_off_t curl_prot_t;
/* This mask is for all the old protocols that are provided and defined in the
public header and shall exclude protocols added since which are not exposed
in the API */
#define CURLPROTO_MASK (0x3ffffff)
#define CURLPROTO_MASK 0x3ffffff
#define CURL_DEFAULT_USER "anonymous"
#define CURL_DEFAULT_PASSWORD "ftp@example.com"

View file

@ -2063,8 +2063,7 @@ static CURLcode cf_progress_egress(struct Curl_cfilter *cf,
pktcnt = 0;
}
else if(nread < gsolen) {
/* Reached MAX_PKT_BURST *or*
* the capacity of our buffer *or*
/* Reached capacity of our buffer *or*
* last add was shorter than the previous ones, flush */
break;
}

View file

@ -382,7 +382,7 @@ if(!$filedate) {
}
# get the hash from the download file
my $newhash= sha256($txt);
my $newhash = sha256($txt);
if(!$opt_f && $oldhash eq $newhash) {
report "Downloaded file identical to previous run\'s source file. Exiting";
@ -426,7 +426,7 @@ print CRT <<EOT;
EOT
report "Processing '$txt' ...";
report "Processing '$txt' ...";
my $caname;
my $certnum = 0;
my $skipnum = 0;

View file

@ -216,7 +216,7 @@ endif
endif
_tidy_cflags :=
TIDYFLAGS =
TIDYFLAGS :=
if CURL_WERROR
TIDYFLAGS += '--warnings-as-errors=*'
endif

View file

@ -43,9 +43,7 @@ static CURLcode test_lib560(const char *URL)
start_test_timing();
/*
** curl_global_init called indirectly from curl_easy_init.
*/
/* curl_global_init called indirectly from curl_easy_init */
easy_init(curl);

View file

@ -79,7 +79,7 @@ my @not_built_in_num = (
#
my $allowedstringerrors = <<MOO
switch(code) {
switch(result) {
case CURLE_BAD_FUNCTION_ARGUMENT:
MOO
;
@ -137,7 +137,7 @@ MOO
#
my $allowednumerrors = <<MOO
switch(code) {
switch(result) {
case CURLE_UNSUPPORTED_PROTOCOL:
MOO
;
@ -240,50 +240,50 @@ static size_t readcb(char *buffer,
return 0;
}
static void errlongzero(const char *name, CURLcode code, int lineno)
static void errlongzero(const char *name, CURLcode result, int lineno)
{
curl_mprintf("%s set to 0 returned %d, \\"%s\\" on line %d\\n",
name, code, curl_easy_strerror(code), lineno);
name, result, curl_easy_strerror(result), lineno);
}
static void errlong(const char *name, CURLcode code, int lineno)
static void errlong(const char *name, CURLcode result, int lineno)
{
$allowednumerrors
curl_mprintf("%s set to non-zero returned %d, \\"%s\\" on line %d\\n",
name, code, curl_easy_strerror(code), lineno);
name, result, curl_easy_strerror(result), lineno);
}
static void errneg(const char *name, CURLcode code, int lineno)
static void errneg(const char *name, CURLcode result, int lineno)
{
curl_mprintf("%s set to -1 returned %d, \\"%s\\" on line %d\\n",
name, code, curl_easy_strerror(code), lineno);
name, result, curl_easy_strerror(result), lineno);
}
static void errstring(const char *name, CURLcode code, int lineno)
static void errstring(const char *name, CURLcode result, int lineno)
{
/* allow this set of options to return CURLE_BAD_FUNCTION_ARGUMENT
when given a strange string input */
$allowedstringerrors
curl_mprintf("%s set to a string returned %d, \\"%s\\" on line %d\\n",
name, code, curl_easy_strerror(code), lineno);
name, result, curl_easy_strerror(result), lineno);
}
static void err(const char *name, CURLcode val, int lineno)
static void err(const char *name, CURLcode result, int lineno)
{
curl_mprintf("%s returned %d, \\"%s\\" on line %d\\n",
name, val, curl_easy_strerror(val), lineno);
name, result, curl_easy_strerror(result), lineno);
}
static void errnull(const char *name, CURLcode val, int lineno)
static void errnull(const char *name, CURLcode result, int lineno)
{
curl_mprintf("%s set to NULL returned %d, \\"%s\\" on line %d\\n",
name, val, curl_easy_strerror(val), lineno);
name, result, curl_easy_strerror(result), lineno);
}
static void t1521_geterr(const char *name, CURLcode val, int lineno)
static void t1521_geterr(const char *name, CURLcode result, int lineno)
{
curl_mprintf("CURLINFO_%s returned %d, \\"%s\\" on line %d\\n",
name, val, curl_easy_strerror(val), lineno);
name, result, curl_easy_strerror(result), lineno);
}
static curl_progress_callback progresscb;

View file

@ -200,11 +200,11 @@ static int decodedata(char **buf, /* dest buffer */
if(!src_len) {
/*
** currently there is no way to tell apart an OOM condition in
** curlx_base64_decode() from zero length decoded data. For now,
** let's just assume it is an OOM condition, currently we have
** no input for this function that decodes to zero length data.
*/
* currently there is no way to tell apart an OOM condition in
* curlx_base64_decode() from zero length decoded data. For now,
* let's just assume it is an OOM condition, currently we have
* no input for this function that decodes to zero length data.
*/
free(buf64);
return GPE_OUT_OF_MEMORY;
@ -300,8 +300,8 @@ int getpart(char **outbuf, size_t *outlen,
if('/' == *ptr) {
/*
** closing section tag
*/
* closing section tag
*/
ptr++;
end = ptr;
@ -356,8 +356,8 @@ int getpart(char **outbuf, size_t *outlen,
}
else if(!in_wanted_part) {
/*
** opening section tag
*/
* opening section tag
*/
/* get potential tag */
end = ptr;

View file

@ -619,7 +619,7 @@ static int rtspd_get_request(curl_socket_t sock, struct rtspd_httprequest *req)
pipereq_length = req->offset - req->checkindex;
}
/*** Init the httprequest structure properly for the upcoming request ***/
/* Init the httprequest structure properly for the upcoming request */
req->checkindex = 0;
req->offset = 0;
@ -640,7 +640,7 @@ static int rtspd_get_request(curl_socket_t sock, struct rtspd_httprequest *req)
req->rtp_buffer = NULL;
req->rtp_buffersize = 0;
/*** end of httprequest init ***/
/* end of httprequest init */
while(!done_processing && (req->offset < sizeof(req->reqbuf) - 1)) {
if(pipereq_length && pipereq) {
@ -1212,9 +1212,9 @@ static int test_rtspd(int argc, const char *argv[])
}
/*
** As soon as this server writes its pid file the test harness will
** attempt to connect to this server and initiate its verification.
*/
* As soon as this server writes its pid file the test harness will
* attempt to connect to this server and initiate its verification.
*/
wrotepidfile = write_pidfile(pidname);
if(!wrotepidfile)
@ -1239,10 +1239,10 @@ static int test_rtspd(int argc, const char *argv[])
}
/*
** As soon as this server accepts a connection from the test harness it
** must set the server logs advisor read lock to indicate that server
** logs should not be read until this lock is removed by this server.
*/
* As soon as this server accepts a connection from the test harness it
* must set the server logs advisor read lock to indicate that server
* logs should not be read until this lock is removed by this server.
*/
set_advisor_read_lock(loglockfile);
serverlogslocked = 1;

View file

@ -1855,10 +1855,10 @@ static curl_socket_t accept_connection(curl_socket_t sock)
#endif
/*
** As soon as this server accepts a connection from the test harness it
** must set the server logs advisor read lock to indicate that server
** logs should not be read until this lock is removed by this server.
*/
* As soon as this server accepts a connection from the test harness it
* must set the server logs advisor read lock to indicate that server
* logs should not be read until this lock is removed by this server.
*/
if(!serverlogslocked)
set_advisor_read_lock(loglockfile);
@ -2275,9 +2275,9 @@ static int test_sws(int argc, const char *argv[])
#endif
/*
** As soon as this server writes its pid file the test harness will
** attempt to connect to this server and initiate its verification.
*/
* As soon as this server writes its pid file the test harness will
* attempt to connect to this server and initiate its verification.
*/
wrotepidfile = write_pidfile(pidname);
if(!wrotepidfile)

View file

@ -254,10 +254,10 @@ void clear_advisor_read_lock(const char *filename)
int res;
/*
** Log all removal failures. Even those due to file not existing.
** This allows to detect if unexpectedly the file has already been
** removed by a process different than the one that should do this.
*/
* Log all removal failures. Even those due to file not existing.
* This allows to detect if unexpectedly the file has already been
* removed by a process different than the one that should do this.
*/
do {
res = unlink(filename);

View file

@ -171,7 +171,7 @@ for my $e (sort @syms) {
#
# CURL_TEMP_ - are defined and *undefined* again within the file
#
# *_LAST and *_LASTENTRY are just prefix for the placeholders used for the
# *_LAST and *_LASTENTRY are just suffix for the placeholders used for the
# last entry in many enum series.
#

View file

@ -38,9 +38,7 @@ static CURLcode test_unit1398(const char *arg)
int width = 3;
char output[130];
#if 0
#define curl_msnprintf snprintf
#endif
/* #define curl_msnprintf snprintf */
/* without a trailing zero */
rc = curl_msnprintf(output, 4, "%.*s", width, buf);

View file

@ -94,12 +94,12 @@ static CURLcode test_unit2604(const char *arg)
}
if(!result) {
if(cp && strcmp(cp, list[i].next)) {
curl_mprintf("... cp points to '%s', not '%s' as expected \n",
curl_mprintf("... cp points to '%s', not '%s' as expected\n",
cp, list[i].next);
unitfail++;
}
if(path && strcmp(path, list[i].expect)) {
curl_mprintf("... gave '%s', not '%s' as expected \n",
curl_mprintf("... gave '%s', not '%s' as expected\n",
path, list[i].expect);
unitfail++;
}

View file

@ -88,12 +88,12 @@ static CURLcode test_unit2605(const char *arg)
}
if(!result) {
if(start != list[i].start) {
curl_mprintf("... start (%" FMT_OFF_T ") was not %" FMT_OFF_T " \n",
curl_mprintf("... start (%" FMT_OFF_T ") was not %" FMT_OFF_T "\n",
start, list[i].start);
unitfail++;
}
if(size != list[i].size) {
curl_mprintf("... size (%" FMT_OFF_T ") was not %" FMT_OFF_T " \n",
curl_mprintf("... size (%" FMT_OFF_T ") was not %" FMT_OFF_T "\n",
size, list[i].size);
unitfail++;
}