tidy-up: use more static, sizeof(), char[], double-const

- make `const` data `static`, where missing and possible.
- replace `strlen()` on literal or const strings with `sizeof()`.
  While the latter is optimized by popular C compiler, e.g. MSVC only
  does it with `/O2`.
- replace magic numbers with `sizeof()`, where missing.
- introduce `CURL_CSTRLEN()` macro for `sizeof(char[]) - 1`.
- use `CURL_CSTRLEN()` macro.
- move `const` before integer types, where missing.
- replace `char *var` with `var[]`, where missing and possible.
- use double const, where missing.
  `static const char *` -> `static const char * const`.
- lib1514: constify pointers.
- unit3205: drop redundant cast, avoid another one.
- unit1666: map `OID()` macro to identical `STRCONST()`.

Closes #22406
This commit is contained in:
Viktor Szakats 2026-07-23 01:50:06 +02:00
parent 573a6ec16b
commit e1450d8fda
No known key found for this signature in database
117 changed files with 311 additions and 287 deletions

View file

@ -215,7 +215,7 @@ static CURLcode http_proxy_create_CONNECT(struct httpreq **preq,
goto out;
}
result = Curl_http_req_make(&req, "CONNECT", sizeof("CONNECT") - 1,
result = Curl_http_req_make(&req, "CONNECT", CURL_CSTRLEN("CONNECT"),
NULL, 0, authority, strlen(authority),
NULL, 0);
if(result)
@ -340,7 +340,7 @@ static CURLcode http_proxy_create_CONNECTUDP(struct httpreq **preq,
}
if(ver == PROXY_HTTP_V1) {
result = Curl_http_req_make(&req, "GET", sizeof("GET")-1,
result = Curl_http_req_make(&req, "GET", CURL_CSTRLEN("GET"),
proxy_scheme, strlen(proxy_scheme),
authority, strlen(authority),
path, strlen(path));
@ -348,7 +348,7 @@ static CURLcode http_proxy_create_CONNECTUDP(struct httpreq **preq,
goto out;
}
else if(ver == PROXY_HTTP_V2 || ver == PROXY_HTTP_V3) {
result = Curl_http_req_make(&req, "CONNECT", sizeof("CONNECT") - 1,
result = Curl_http_req_make(&req, "CONNECT", CURL_CSTRLEN("CONNECT"),
proxy_scheme, strlen(proxy_scheme),
authority, strlen(authority),
path, strlen(path));