tidy-up: miscellaneous

- tool_bname: scope an include.
- `endif` comments.
- Markdown fixes.
- comment tidy-ups.
- whitespace, newlines, indent.

Closes #20309
This commit is contained in:
Viktor Szakats 2026-01-02 01:34:05 +01:00
parent 62ba3604dc
commit ac6264366f
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
98 changed files with 829 additions and 863 deletions

View file

@ -146,8 +146,7 @@ CS_1 =
CS_ = $(CS_0)
checksrc:
$(CHECKSRC)(@PERL@ $(top_srcdir)/scripts/checksrc.pl -D$(srcdir) \
$(CSOURCES) $(HHEADERS))
$(CHECKSRC)(@PERL@ $(top_srcdir)/scripts/checksrc.pl -D$(srcdir) $(CSOURCES) $(HHEADERS))
if NOT_CURL_CI
if DEBUGBUILD

View file

@ -30,10 +30,8 @@
/* Only include this function if one or more of FTP, FILE are enabled. */
#if !defined(CURL_DISABLE_FTP) || !defined(CURL_DISABLE_FILE)
/*
Check if this is a range download, and if so, set the internal variables
properly.
*/
/* Check if this is a range download, and if so, set the internal variables
properly. */
CURLcode Curl_range(struct Curl_easy *data)
{
if(data->state.use_range && data->state.range) {

View file

@ -711,9 +711,9 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct Curl_easy *data,
struct kerberos5data *krb5 = Curl_auth_krb5_get(conn);
result = !krb5 ? CURLE_OUT_OF_MEMORY :
Curl_auth_create_gssapi_user_message(data, conn->user, conn->passwd,
service, conn->host.name,
sasl->mutual_auth, NULL,
krb5, &resp);
service, conn->host.name,
sasl->mutual_auth, NULL,
krb5, &resp);
newstate = SASL_GSSAPI_TOKEN;
break;
}

View file

@ -147,7 +147,7 @@ static CURLcode Curl_sha512_256_update(void *context,
*
* @param context the calculation context
* @param[out] digest set to the hash, must be #CURL_SHA512_256_DIGEST_SIZE
# bytes
* bytes
* @return CURLE_OK if succeed,
* error code otherwise
*/
@ -229,7 +229,7 @@ static CURLcode Curl_sha512_256_update(void *context,
*
* @param context the calculation context
* @param[out] digest set to the hash, must be #CURL_SHA512_256_DIGEST_SIZE
# bytes
* bytes
* @return always CURLE_OK
*/
static CURLcode Curl_sha512_256_finish(unsigned char *digest, void *context)
@ -663,7 +663,7 @@ static CURLcode Curl_sha512_256_update(void *context,
*
* @param context the calculation context
* @param[out] digest set to the hash, must be #CURL_SHA512_256_DIGEST_SIZE
# bytes
* bytes
* @return always CURLE_OK
*/
static CURLcode Curl_sha512_256_finish(unsigned char *digest, void *context)

View file

@ -54,11 +54,11 @@ int curlx_win32_rename(const char *oldpath, const char *newpath);
#define curlx_open curlx_win32_open
#define curlx_rename curlx_win32_rename
#else
#define CURLX_FOPEN_LOW fopen
#define CURLX_FREOPEN_LOW freopen
#define curlx_stat(fname, stp) stat(fname, stp)
#define curlx_open open
#define curlx_rename rename
#define CURLX_FOPEN_LOW fopen
#define CURLX_FREOPEN_LOW freopen
#define curlx_stat(fname, stp) stat(fname, stp)
#define curlx_open open
#define curlx_rename rename
#endif
#ifdef CURLDEBUG

View file

@ -361,7 +361,7 @@ CURL *curl_easy_init(void)
}
global_init_unlock();
/* We use curl_open() with undefined URL so far */
/* We use Curl_open() with undefined URL so far */
result = Curl_open(&data);
if(result) {
DEBUGF(curl_mfprintf(stderr, "Error: Curl_open failed\n"));

View file

@ -840,8 +840,7 @@ CURLcode Curl_getformdata(CURL *data,
return result;
}
#else
/* if disabled */
#else /* if disabled */
CURLFORMcode curl_formadd(struct curl_httppost **httppost,
struct curl_httppost **last_post, ...)
{

View file

@ -115,6 +115,7 @@ static void curl_dbg_cleanup(void)
}
#endif
}
#ifdef USE_BACKTRACE
static void error_bt_callback(void *data, const char *message,
int error_number)

View file

@ -35,10 +35,9 @@ struct Curl_easy;
#include "curlx/fopen.h"
#include "curlx/base64.h"
#if !defined(CURL_DISABLE_MIME) && \
(!defined(CURL_DISABLE_HTTP) || \
!defined(CURL_DISABLE_SMTP) || \
!defined(CURL_DISABLE_IMAP))
#if !defined(CURL_DISABLE_MIME) && (!defined(CURL_DISABLE_HTTP) || \
!defined(CURL_DISABLE_SMTP) || \
!defined(CURL_DISABLE_IMAP))
#if defined(HAVE_LIBGEN_H) && defined(HAVE_BASENAME)
#include <libgen.h>
@ -95,7 +94,7 @@ static const char aschex[] =
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x41\x42\x43\x44\x45\x46";
#ifndef __VMS
#define filesize(name, stat_data) (stat_data.st_size)
#define filesize(name, stat_data) stat_data.st_size
#define fopen_read curlx_fopen
#else
@ -181,7 +180,7 @@ static FILE *vmsfopenread(const char *file, const char *mode)
}
#define fopen_read vmsfopenread
#endif
#endif /* !__VMS */
#ifndef HAVE_BASENAME
/*
@ -230,7 +229,7 @@ static char *Curl_basename(char *path)
}
#define basename(x) Curl_basename(x)
#endif
#endif /* !HAVE_BASENAME */
/* Set readback state. */
static void mimesetstate(struct mime_state *state,
@ -2175,7 +2174,8 @@ CURLcode Curl_creader_set_mime(struct Curl_easy *data, curl_mimepart *part)
}
#else /* !CURL_DISABLE_MIME && (!CURL_DISABLE_HTTP ||
!CURL_DISABLE_SMTP || !CURL_DISABLE_IMAP) */
!CURL_DISABLE_SMTP ||
!CURL_DISABLE_IMAP) */
/* Mime not compiled in: define stubs for externally-referenced functions. */
curl_mime *curl_mime_init(CURL *easy)

View file

@ -160,8 +160,7 @@ const char *Curl_mime_contenttype(const char *filename);
*/
CURLcode Curl_creader_set_mime(struct Curl_easy *data, curl_mimepart *part);
#else
/* if disabled */
#else /* if disabled */
#define Curl_mime_initpart(x)
#define Curl_mime_cleanpart(x)
#define Curl_mime_duppart(x, y, z) CURLE_OK /* Nothing to duplicate. Succeed */

View file

@ -517,8 +517,8 @@ CURLMcode curl_multi_add_handle(CURLM *m, CURL *d)
data->set.server_response_timeout;
multi->admin->set.no_signal = data->set.no_signal;
CURL_TRC_M(data, "added to multi, mid=%u, running=%u"
", total=%u", data->mid, Curl_multi_xfers_running(multi),
CURL_TRC_M(data, "added to multi, mid=%u, running=%u, total=%u",
data->mid, Curl_multi_xfers_running(multi),
Curl_uint32_tbl_count(&multi->xfers));
return CURLM_OK;
}
@ -611,8 +611,7 @@ static void multi_done_locked(struct connectdata *conn,
CURL_TRC_M(data, "multi_done_locked, in use=%u", conn->attached_xfers);
if(CONN_INUSE(conn)) {
/* Stop if still used. */
CURL_TRC_M(data,
"Connection still in use %u, no more multi_done now!",
CURL_TRC_M(data, "Connection still in use %u, no more multi_done now!",
conn->attached_xfers);
return;
}
@ -885,8 +884,8 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d)
return mresult;
}
CURL_TRC_M(data, "removed from multi, mid=%u, running=%u"
", total=%u", mid, Curl_multi_xfers_running(multi),
CURL_TRC_M(data, "removed from multi, mid=%u, running=%u, total=%u",
mid, Curl_multi_xfers_running(multi),
Curl_uint32_tbl_count(&multi->xfers));
return CURLM_OK;
}
@ -2710,19 +2709,17 @@ statemachine_end:
/* A sub transfer, not for msgsent to application */
struct Curl_easy *mdata;
CURL_TRC_M(data, "sub xfer done for master %u",
data->master_mid);
CURL_TRC_M(data, "sub xfer done for master %u", data->master_mid);
mdata = Curl_multi_get_easy(multi, data->master_mid);
if(mdata) {
if(mdata->sub_xfer_done)
mdata->sub_xfer_done(mdata, data, result);
else
CURL_TRC_M(data, "master easy %u"
" without sub_xfer_done callback.", data->master_mid);
CURL_TRC_M(data, "master easy %u without sub_xfer_done callback.",
data->master_mid);
}
else {
CURL_TRC_M(data, "master easy %u already gone.",
data->master_mid);
CURL_TRC_M(data, "master easy %u already gone.", data->master_mid);
}
}
else {
@ -3119,8 +3116,7 @@ static CURLMcode multi_run_dirty(struct multi_run_ctx *mrc)
}
}
else {
CURL_TRC_M(multi->admin,
"multi_run_dirty, %u no longer found", mid);
CURL_TRC_M(multi->admin, "multi_run_dirty, %u no longer found", mid);
Curl_uint32_bset_remove(&multi->dirty, mid);
}
} while(Curl_uint32_bset_next(&multi->dirty, mid, &mid));
@ -3342,8 +3338,7 @@ static bool multi_has_dirties(struct Curl_multi *multi)
Curl_uint32_bset_remove(&multi->dirty, mid);
}
else {
CURL_TRC_M(multi->admin, "dirty transfer %u no longer found",
mid);
CURL_TRC_M(multi->admin, "dirty transfer %u no longer found", mid);
Curl_uint32_bset_remove(&multi->dirty, mid);
}
} while(Curl_uint32_bset_next(&multi->dirty, mid, &mid));
@ -3986,8 +3981,8 @@ struct Curl_easy *Curl_multi_get_easy(struct Curl_multi *multi,
struct Curl_easy *data = Curl_uint32_tbl_get(&multi->xfers, mid);
if(data && GOOD_EASY_HANDLE(data))
return data;
CURL_TRC_M(multi->admin,
"invalid easy handle in xfer table for mid=%u", mid);
CURL_TRC_M(multi->admin, "invalid easy handle in xfer table for mid=%u",
mid);
Curl_uint32_tbl_remove(&multi->xfers, mid);
return NULL;
}

View file

@ -581,8 +581,7 @@ void Curl_multi_ev_dirty_xfers(struct Curl_multi *multi,
Curl_multi_mark_dirty(data);
}
else {
CURL_TRC_M(multi->admin,
"socket transfer %u no longer found", mid);
CURL_TRC_M(multi->admin, "socket transfer %u no longer found", mid);
Curl_uint32_spbset_remove(&entry->xfers, mid);
}
} while(Curl_uint32_spbset_next(&entry->xfers, mid, &mid));

View file

@ -110,8 +110,7 @@ static void mntfy_chunk_dispatch_all(struct Curl_multi *multi,
/* only when notification has not been disabled in the meantime */
if(data && Curl_uint32_bset_contains(&multi->ntfy.enabled, e->type)) {
/* this may cause new notifications to be added! */
CURL_TRC_M(multi->admin,
"[NTFY] dispatch %u to xfer %u",
CURL_TRC_M(multi->admin, "[NTFY] dispatch %u to xfer %u",
e->type, e->mid);
multi->ntfy.ntfy_cb(multi, e->type, data, multi->ntfy.ntfy_cb_data);
}

View file

@ -1295,11 +1295,11 @@ upgrade_tls:
if(pp->sendleft)
return Curl_pp_flushsend(data, pp);
do {
/* Read the response from the server */
result = Curl_pp_readresp(data, FIRSTSOCKET, pp, &pop3code, &nread);
if(result)
return result;
do {
/* Read the response from the server */
result = Curl_pp_readresp(data, FIRSTSOCKET, pp, &pop3code, &nread);
if(result)
return result;
if(!pop3code)
break;

View file

@ -180,7 +180,6 @@ const struct curltime *Curl_pgrs_now(struct Curl_easy *data)
}
/*
New proposed interface, 9th of February 2000:
pgrsStartNow() - sets start time
@ -190,7 +189,6 @@ const struct curltime *Curl_pgrs_now(struct Curl_easy *data)
pgrsSetUploadCounter() - amount of data currently uploaded
pgrsUpdate() - show progress
pgrsDone() - transfer complete
*/
int Curl_pgrsDone(struct Curl_easy *data)
@ -243,7 +241,6 @@ void Curl_pgrsSendPause(struct Curl_easy *data, bool enable)
}
/*
*
* Curl_pgrsTimeWas(). Store the timestamp time at the given label.
*/
void Curl_pgrsTimeWas(struct Curl_easy *data, timerid timer,
@ -290,8 +287,8 @@ void Curl_pgrsTimeWas(struct Curl_easy *data, timerid timer,
case TIMER_STARTTRANSFER:
delta = &data->progress.t_starttransfer;
/* prevent updating t_starttransfer unless:
* 1) this is the first time we are setting t_starttransfer
* 2) a redirect has occurred since the last time t_starttransfer was set
* 1. this is the first time we are setting t_starttransfer
* 2. a redirect has occurred since the last time t_starttransfer was set
* This prevents repeated invocations of the function from incorrectly
* changing the t_starttransfer time.
*/
@ -321,7 +318,6 @@ void Curl_pgrsTimeWas(struct Curl_easy *data, timerid timer,
}
/*
*
* Curl_pgrsTime(). Store the current time at the given label. This fetches a
* fresh "now" and returns it.
*
@ -607,8 +603,7 @@ static void progress_meter(struct Curl_easy *data)
/* we flush the output stream to make it appear as soon as possible */
fflush(data->set.err);
}
#else
/* progress bar disabled */
#else /* CURL_DISABLE_PROGRESS_METER */
#define progress_meter(x) Curl_nop_stmt
#endif

View file

@ -1,5 +1,5 @@
#ifndef HEADER_Curl_rlimit_H
#define HEADER_Curl_rlimit_H
#ifndef HEADER_CURL_RLIMIT_H
#define HEADER_CURL_RLIMIT_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@ -90,4 +90,4 @@ void Curl_rlimit_block(struct Curl_rlimit *r,
bool activate,
const struct curltime *pts);
#endif /* HEADER_Curl_rlimit_H */
#endif /* HEADER_CURL_RLIMIT_H */

View file

@ -549,7 +549,6 @@ const char *Curl_sspi_strerror(SECURITY_STATUS err, char *buf, size_t buflen)
*buf = '\0';
#ifndef CURL_DISABLE_VERBOSE_STRINGS
switch(err) {
case SEC_E_OK:
txt = "No error";
@ -657,7 +656,6 @@ const char *Curl_sspi_strerror(SECURITY_STATUS err, char *buf, size_t buflen)
else
curl_msnprintf(buf, buflen, "%s (0x%08lx)", txt, err);
}
#else
if(err == SEC_E_OK)
txt = "No error";

View file

@ -35,7 +35,7 @@ void Curl_init_userdefined(struct Curl_easy *data);
void Curl_freeset(struct Curl_easy *data);
CURLcode Curl_uc_to_curlcode(CURLUcode uc);
CURLcode Curl_close(struct Curl_easy **datap); /* opposite of curl_open() */
CURLcode Curl_close(struct Curl_easy **datap); /* opposite of Curl_open() */
CURLcode Curl_connect(struct Curl_easy *, bool *async, bool *protocol_connect);
CURLcode Curl_setup_conn(struct Curl_easy *data,
struct Curl_dns_entry *dns,

View file

@ -31,7 +31,6 @@
#include "../curl_hmac.h"
#include "../curl_md5.h"
/*
* Curl_auth_create_cram_md5_message()
*

View file

@ -147,7 +147,6 @@ bool Curl_auth_allowed_to_host(struct Curl_easy *data)
}
#ifdef USE_NTLM
static void ntlm_conn_dtor(void *key, size_t klen, void *entry)
{
struct ntlmdata *ntlm = entry;
@ -175,11 +174,9 @@ void Curl_auth_ntlm_remove(struct connectdata *conn, bool proxy)
Curl_conn_meta_remove(conn, proxy ? CURL_META_NTLM_PROXY_CONN
: CURL_META_NTLM_CONN);
}
#endif /* USE_NTLM */
#ifdef USE_KERBEROS5
static void krb5_conn_dtor(void *key, size_t klen, void *entry)
{
struct kerberos5data *krb5 = entry;
@ -201,11 +198,9 @@ struct kerberos5data *Curl_auth_krb5_get(struct connectdata *conn)
}
return krb5;
}
#endif /* USE_KERBEROS5 */
#ifdef USE_GSASL
static void gsasl_conn_dtor(void *key, size_t klen, void *entry)
{
struct gsasldata *gsasl = entry;
@ -227,11 +222,9 @@ struct gsasldata *Curl_auth_gsasl_get(struct connectdata *conn)
}
return gsasl;
}
#endif /* USE_GSASL */
#ifdef USE_SPNEGO
static void nego_conn_dtor(void *key, size_t klen, void *entry)
{
struct negotiatedata *nego = entry;
@ -253,5 +246,4 @@ struct negotiatedata *Curl_auth_nego_get(struct connectdata *conn, bool proxy)
}
return nego;
}
#endif /* USE_SPNEGO */

View file

@ -1395,13 +1395,13 @@ static CURLcode schannel_connect_step2(struct Curl_cfilter *cf,
inbuf[1].cbBuffer));
/*
There are two cases where we could be getting extra data here:
1) If we are renegotiating a connection and the handshake is already
complete (from the server perspective), it can encrypted app data
(not handshake data) in an extra buffer at this point.
2) (sspi_status == SEC_I_CONTINUE_NEEDED) We are negotiating a
connection and this extra data is part of the handshake.
We should process the data immediately; waiting for the socket to
be ready may fail since the server is done sending handshake data.
1. If we are renegotiating a connection and the handshake is already
complete (from the server perspective), it can encrypted app data
(not handshake data) in an extra buffer at this point.
2. (sspi_status == SEC_I_CONTINUE_NEEDED) We are negotiating a
connection and this extra data is part of the handshake.
We should process the data immediately; waiting for the socket to
be ready may fail since the server is done sending handshake data.
*/
/* check if the remaining data is less than the total amount
and therefore begins after the already processed data */