build: use more const

Mostly with `char *` types.

Also:
- mime, x509asn1, tool_operate, lib3207: drop redundant casts.
- examples/smooth-gtk-thread: add missing variable declaration.
- reduce variable scopes.
- tests/server: move `data_to_hex()` to its only user: `sws`.

Closes #20489
This commit is contained in:
Viktor Szakats 2026-02-01 03:57:45 +01:00
parent 66bb641331
commit 9630593650
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
111 changed files with 278 additions and 268 deletions

View file

@ -257,7 +257,7 @@ static const char *disabled[] = {
#endif
};
int main(int argc, char **argv)
int main(int argc, const char **argv)
{
size_t i;

View file

@ -66,8 +66,8 @@ static void write_linked_location(CURL *curl, const char *location,
{
/* This would so simple if CURLINFO_REDIRECT_URL were available here */
CURLU *u = NULL;
char *copyloc = NULL, *locurl = NULL, *scheme = NULL, *finalurl = NULL;
const char *loc = location;
char *copyloc = NULL, *scheme = NULL, *finalurl = NULL;
const char *loc = location, *locurl = NULL;
size_t llen = loclen;
int space_skipped = 0;
const char *vver = getenv("VTE_VERSION");

View file

@ -96,7 +96,7 @@ int SetHTTPrequest(HttpReq req, HttpReq *store)
return 1;
}
void customrequest_helper(HttpReq req, char *method)
void customrequest_helper(HttpReq req, const char *method)
{
/* this mirrors the HttpReq enum in tool_sdecls.h */
const char *dflt[] = {

View file

@ -27,6 +27,6 @@
const char *param2text(ParameterError error);
int SetHTTPrequest(HttpReq req, HttpReq *store);
void customrequest_helper(HttpReq req, char *method);
void customrequest_helper(HttpReq req, const char *method);
#endif /* HEADER_CURL_TOOL_HELPERS_H */

View file

@ -1753,7 +1753,7 @@ static CURLcode check_finished(struct parastate *s)
struct per_transfer *ended;
CURL *easy = msg->easy_handle;
CURLcode tres = msg->data.result;
curl_easy_getinfo(easy, CURLINFO_PRIVATE, (void *)&ended);
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &ended);
curl_multi_remove_handle(s->multi, easy);
if(ended->abort && (tres == CURLE_ABORTED_BY_CALLBACK)) {
@ -2022,7 +2022,7 @@ static CURLcode is_using_schannel(int *pusing)
if(using_schannel == -1) {
CURL *curltls = curl_easy_init();
/* The TLS backend remains, so keep the info */
struct curl_tlssessioninfo *tls_backend_info = NULL;
const struct curl_tlssessioninfo *tls_backend_info = NULL;
if(!curltls)
result = CURLE_OUT_OF_MEMORY;

View file

@ -34,7 +34,7 @@ struct per_transfer {
struct per_transfer *next;
struct per_transfer *prev;
struct OperationConfig *config; /* for this transfer */
struct curl_certinfo *certinfo;
const struct curl_certinfo *certinfo;
CURL *curl;
long retry_remaining;
long retry_sleep_default;

View file

@ -277,7 +277,7 @@ static bool get_line(FILE *input, struct dynbuf *buf, bool *error)
char buffer[128];
curlx_dyn_reset(buf);
while(1) {
char *b = fgets(buffer, sizeof(buffer), input);
const char *b = fgets(buffer, sizeof(buffer), input);
if(b) {
size_t rlen = strlen(b);

View file

@ -86,7 +86,7 @@ static int urlpart(struct per_transfer *per, writeoutid vid,
if(uh) {
CURLUPart cpart = CURLUPART_HOST;
char *part = NULL;
const char *url = NULL;
char *url = NULL;
if(vid >= VAR_INPUT_URLESCHEME) {
if(curl_easy_getinfo(per->curl, CURLINFO_EFFECTIVE_URL, &url))
@ -162,7 +162,7 @@ static int urlpart(struct per_transfer *per, writeoutid vid,
static void certinfo(struct per_transfer *per)
{
if(!per->certinfo) {
struct curl_certinfo *certinfo;
const struct curl_certinfo *certinfo;
CURLcode result = curl_easy_getinfo(per->curl, CURLINFO_CERTINFO,
&certinfo);
per->certinfo = (!result && certinfo) ? certinfo : NULL;