GHA/checksrc: expand spellcheck, fix issues found

- codespell: break logic out into its own runnable script. Allowing
  to run it on local machines.
- codespell: install via `pip`, bump to latest version.
- codespell: show version number in CI log.
- codespell: drop no longer needed word exception: `msdos`.
- codespell: include all curl source tree, except `packages` and
  `winbuild`. Drop an obsolete file exclusion.
- add new spellchecker job using the `typos` tool. It includes
  the codespell dictionary and a couple more. Use linuxbrew to install
  it. This takes 10 seconds, while installing via `cargo` from source
  would take over a minute.
- codespell: introduce an inline ignore filter compatible with `cspell`
  Make `typos` recognize it, too. Move single exceptions inline.

Fix new typos found. Also rename variables and words to keep
spellchecking exceptions at minumum. This involves touching some tests.
Also switch base64 strings to `%b64[]` to avoid false positives.

Ref: https://github.com/crate-ci/typos/blob/master/docs/reference.md
Ref: https://github.com/codespell-project/codespell?tab=readme-ov-file#inline-ignore
Ref: https://github.com/codespell-project/codespell/issues/1212#issuecomment-1721152455
Ref: https://cspell.org/docs/Configuration/document-settings

Closes #17905
This commit is contained in:
Viktor Szakats 2025-07-11 21:50:23 +02:00
parent 792a61e204
commit 0260e8465a
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
81 changed files with 279 additions and 206 deletions

View file

@ -242,7 +242,7 @@ CURL_STDCALL getaddrinfo_thread(void *arg)
#endif
/* DNS has been resolved, signal client task */
if(wakeup_write(addr_ctx->sock_pair[1], buf, sizeof(buf)) < 0) {
/* update sock_erro to errno */
/* update sock_error to errno */
addr_ctx->sock_error = SOCKERRNO;
}
}

View file

@ -71,14 +71,14 @@ void curlx_dyn_free(struct dynbuf *s)
static CURLcode dyn_nappend(struct dynbuf *s,
const unsigned char *mem, size_t len)
{
size_t indx = s->leng;
size_t idx = s->leng;
size_t a = s->allc;
size_t fit = len + indx + 1; /* new string + old string + zero byte */
size_t fit = len + idx + 1; /* new string + old string + zero byte */
/* try to detect if there is rubbish in the struct */
DEBUGASSERT(s->init == DYNINIT);
DEBUGASSERT(s->toobig);
DEBUGASSERT(indx < s->toobig);
DEBUGASSERT(idx < s->toobig);
DEBUGASSERT(!s->leng || s->bufr);
DEBUGASSERT(a <= s->toobig);
DEBUGASSERT(!len || mem);
@ -88,7 +88,7 @@ static CURLcode dyn_nappend(struct dynbuf *s,
return CURLE_TOO_LARGE;
}
else if(!a) {
DEBUGASSERT(!indx);
DEBUGASSERT(!idx);
/* first invoke */
if(MIN_FIRST_ALLOC > s->toobig)
a = s->toobig;
@ -118,8 +118,8 @@ static CURLcode dyn_nappend(struct dynbuf *s,
}
if(len)
memcpy(&s->bufr[indx], mem, len);
s->leng = indx + len;
memcpy(&s->bufr[idx], mem, len);
s->leng = idx + len;
s->bufr[s->leng] = 0;
return CURLE_OK;
}

View file

@ -54,7 +54,7 @@
*
* Returns `dst' (as a const)
* Note:
* - uses no statics
* - uses no static variables
* - takes an unsigned char* not an in_addr as input
*/
static char *inet_ntop4(const unsigned char *src, char *dst, size_t size)

View file

@ -172,7 +172,7 @@ struct curltime curlx_now(void)
(void) mach_timebase_info(&timebase);
usecs = mach_absolute_time();
usecs *= timebase.numer;
usecs *= timebase.numer; /* spellchecker:disable-line */
usecs /= timebase.denom;
usecs /= 1000;

View file

@ -2067,7 +2067,7 @@ static CURLcode client_write_header(struct Curl_easy *data,
* the body write callback when data->set.include_header is set
* via CURLOPT_HEADER.
* For historic reasons, FTP never played this game and expects
* all its HEADERs to do that always. Set that flag during the
* all its headers to do that always. Set that flag during the
* call to Curl_client_write() so it does the right thing.
*
* Notice that we cannot enable this flag for FTP in general,

View file

@ -145,7 +145,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
return NULL; /* major failure */
/*
* The clearing of the buffer is a workaround for a gethostbyname_r bug in
* qnx nto and it is also _required_ for some of these functions on some
* QNX Neutrino and it is also _required_ for some of these functions on some
* platforms.
*/

View file

@ -2348,7 +2348,7 @@ static CURLcode cf_h2_send(struct Curl_cfilter *cf, struct Curl_easy *data,
DEBUGASSERT(stream);
}
else if(stream->body_eos) {
/* We already wrote this, but CURLE_AGAINed the call due to not
/* We already wrote this, but CURLE_AGAIN-ed the call due to not
* being able to flush stream->sendbuf. Make a 0-length write
* to trigger flushing again.
* If this works, we report to have written `len` bytes. */

View file

@ -150,7 +150,7 @@ static const struct tzinfo tz[]= {
{"HDT", 600 tDAYZONE}, /* Hawaii Daylight */
{"CAT", 600}, /* Central Alaska */
{"AHST", 600}, /* Alaska-Hawaii Standard */
{"NT", 660}, /* Nome */
{"NT", 660}, /* Nome */ /* spellchecker:disable-line */
{"IDLW", 720}, /* International Date Line West */
{"CET", -60}, /* Central European */
{"MET", -60}, /* Middle European */
@ -161,7 +161,8 @@ static const struct tzinfo tz[]= {
{"FWT", -60}, /* French Winter */
{"FST", -60 tDAYZONE}, /* French Summer */
{"EET", -120}, /* Eastern Europe, USSR Zone 1 */
{"WAST", -420}, /* West Australian Standard */
{"WAST", -420}, /* spellchecker:disable-line */
/* West Australian Standard */
{"WADT", -420 tDAYZONE}, /* West Australian Daylight */
{"CCT", -480}, /* China Coast, USSR Zone 7 */
{"JST", -540}, /* Japan Standard, USSR Zone 8 */

View file

@ -3717,7 +3717,7 @@ static CURLcode create_conn(struct Curl_easy *data,
*in_connect = conn;
#ifndef CURL_DISABLE_PROXY
infof(data, "Re-using existing %s: connection%s with %s %s",
infof(data, "Reusing existing %s: connection%s with %s %s",
conn->given->scheme,
tls_upgraded ? " (upgraded to SSL)" : "",
conn->bits.proxy ? "proxy" : "host",
@ -3725,7 +3725,7 @@ static CURLcode create_conn(struct Curl_easy *data,
conn->http_proxy.host.name ? conn->http_proxy.host.dispname :
conn->host.dispname);
#else
infof(data, "Re-using existing %s: connection%s with host %s",
infof(data, "Reusing existing %s: connection%s with host %s",
conn->given->scheme,
tls_upgraded ? " (upgraded to SSL)" : "",
conn->host.dispname);

View file

@ -155,7 +155,7 @@ struct cf_ngtcp2_ctx {
BIT(initialized);
BIT(tls_handshake_complete); /* TLS handshake is done */
BIT(use_earlydata); /* Using 0RTT data */
BIT(earlydata_accepted); /* 0RTT was acceptd by server */
BIT(earlydata_accepted); /* 0RTT was accepted by server */
BIT(shutdown_started); /* queued shutdown packets */
};

View file

@ -159,11 +159,11 @@ static char *osslq_strerror(unsigned long error, char *buf, size_t size)
static CURLcode make_bio_addr(BIO_ADDR **pbio_addr,
const struct Curl_sockaddr_ex *addr)
{
BIO_ADDR *ba;
BIO_ADDR *bio_addr;
CURLcode result = CURLE_FAILED_INIT;
ba = BIO_ADDR_new();
if(!ba) {
bio_addr = BIO_ADDR_new();
if(!bio_addr) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
@ -172,7 +172,7 @@ static CURLcode make_bio_addr(BIO_ADDR **pbio_addr,
case AF_INET: {
struct sockaddr_in * const sin =
(struct sockaddr_in * const)CURL_UNCONST(&addr->curl_sa_addr);
if(!BIO_ADDR_rawmake(ba, AF_INET, &sin->sin_addr,
if(!BIO_ADDR_rawmake(bio_addr, AF_INET, &sin->sin_addr,
sizeof(sin->sin_addr), sin->sin_port)) {
goto out;
}
@ -183,7 +183,7 @@ static CURLcode make_bio_addr(BIO_ADDR **pbio_addr,
case AF_INET6: {
struct sockaddr_in6 * const sin =
(struct sockaddr_in6 * const)CURL_UNCONST(&addr->curl_sa_addr);
if(!BIO_ADDR_rawmake(ba, AF_INET6, &sin->sin6_addr,
if(!BIO_ADDR_rawmake(bio_addr, AF_INET6, &sin->sin6_addr,
sizeof(sin->sin6_addr), sin->sin6_port)) {
}
result = CURLE_OK;
@ -197,11 +197,11 @@ static CURLcode make_bio_addr(BIO_ADDR **pbio_addr,
}
out:
if(result && ba) {
BIO_ADDR_free(ba);
ba = NULL;
if(result && bio_addr) {
BIO_ADDR_free(bio_addr);
bio_addr = NULL;
}
*pbio_addr = ba;
*pbio_addr = bio_addr;
return result;
}

View file

@ -70,7 +70,7 @@ static const char *cs_txt =
"ECDH" "\0"
"ECDHE" "\0"
"ECDSA" "\0"
"EDE" "\0"
"EDE" "\0" /* spellchecker:disable-line */
"GCM" "\0"
"MD5" "\0"
"NULL" "\0"
@ -111,7 +111,7 @@ enum {
CS_TXT_IDX_ECDH,
CS_TXT_IDX_ECDHE,
CS_TXT_IDX_ECDSA,
CS_TXT_IDX_EDE,
CS_TXT_IDX_EDE, /* spellchecker:disable-line */
CS_TXT_IDX_GCM,
CS_TXT_IDX_MD5,
CS_TXT_IDX_NULL,

View file

@ -1516,7 +1516,7 @@ int cert_stuff(struct Curl_easy *data,
goto fail;
}
if(!SSL_CTX_check_private_key (ctx)) {
if(!SSL_CTX_check_private_key(ctx)) {
failf(data, "private key from PKCS12 file '%s' "
"does not match certificate in same file", cert_file);
goto fail;

View file

@ -286,7 +286,7 @@ static const struct algo algs[]= {
#ifdef CALG_TEK
CIPHEROPTION(CALG_TEK),
#endif
CIPHEROPTION(CALG_CYLINK_MEK),
CIPHEROPTION(CALG_CYLINK_MEK), /* spellchecker:disable-line */
CIPHEROPTION(CALG_SSL3_SHAMD5),
#ifdef CALG_SSL3_MASTER
CIPHEROPTION(CALG_SSL3_MASTER),

View file

@ -83,7 +83,7 @@ typedef struct _CRYPTO_SETTINGS {
eTlsAlgorithmUsage eAlgorithmUsage;
UNICODE_STRING strCngAlgId;
DWORD cChainingModes;
PUNICODE_STRING rgstrChainingModes;
PUNICODE_STRING rgstrChainingModes; /* spellchecker:disable-line */
DWORD dwMinBitLength;
DWORD dwMaxBitLength;
} CRYPTO_SETTINGS, * PCRYPTO_SETTINGS;
@ -91,7 +91,7 @@ typedef struct _CRYPTO_SETTINGS {
/* !checksrc! disable TYPEDEFSTRUCT 1 */
typedef struct _TLS_PARAMETERS {
DWORD cAlpnIds;
PUNICODE_STRING rgstrAlpnIds;
PUNICODE_STRING rgstrAlpnIds; /* spellchecker:disable-line */
DWORD grbitDisabledProtocols;
DWORD cDisabledCrypto;
PCRYPTO_SETTINGS pDisabledCrypto;

View file

@ -44,7 +44,7 @@ struct wssl_ctx {
struct WOLFSSL *ssl;
CURLcode io_result; /* result of last BIO cfilter operation */
CURLcode hs_result; /* result of handshake */
int io_send_blocked_len; /* length of last BIO write that EAGAINed */
int io_send_blocked_len; /* length of last BIO write that EAGAIN-ed */
BIT(x509_store_setup); /* x509 store has been set up */
BIT(shutting_down); /* TLS is being shut down */
};