lib: fix formatting nits (part 3)

From `lib/h` to `lib/w`.

part 1: 47a1ab2ebe #19764
part 2: 86b346443b #19800

Closes #19811
This commit is contained in:
Viktor Szakats 2025-12-02 07:25:18 +01:00
parent dc8c0d54a5
commit c3b030b860
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
102 changed files with 2001 additions and 2226 deletions

View file

@ -118,7 +118,7 @@ static void dnscache_entry_free(struct Curl_dns_entry *dns);
static void show_resolve_info(struct Curl_easy *data,
struct Curl_dns_entry *dns);
#else
#define show_resolve_info(x,y) Curl_nop_stmt
#define show_resolve_info(x, y) Curl_nop_stmt
#endif
/*
@ -158,10 +158,9 @@ void Curl_printable_address(const struct Curl_addrinfo *ai, char *buf,
* Create a hostcache id string for the provided host + port, to be used by
* the DNS caching. Without alloc. Return length of the id string.
*/
static size_t
create_dnscache_id(const char *name,
size_t nlen, /* 0 or actual name length */
int port, char *ptr, size_t buflen)
static size_t create_dnscache_id(const char *name,
size_t nlen, /* 0 or actual name length */
int port, char *ptr, size_t buflen)
{
size_t len = nlen ? nlen : strlen(name);
DEBUGASSERT(buflen >= MAX_HOSTCACHE_LEN);
@ -185,12 +184,10 @@ struct dnscache_prune_data {
* Returning non-zero means remove the entry, return 0 to keep it in the
* cache.
*/
static int
dnscache_entry_is_stale(void *datap, void *hc)
static int dnscache_entry_is_stale(void *datap, void *hc)
{
struct dnscache_prune_data *prune =
(struct dnscache_prune_data *) datap;
struct Curl_dns_entry *dns = (struct Curl_dns_entry *) hc;
struct dnscache_prune_data *prune = (struct dnscache_prune_data *)datap;
struct Curl_dns_entry *dns = (struct Curl_dns_entry *)hc;
if(dns->timestamp.tv_sec || dns->timestamp.tv_usec) {
/* get age in milliseconds */
@ -209,9 +206,9 @@ dnscache_entry_is_stale(void *datap, void *hc)
* Prune the DNS cache. This assumes that a lock has already been taken.
* Returns the 'age' of the oldest still kept entry - in milliseconds.
*/
static timediff_t
dnscache_prune(struct Curl_hash *hostcache, timediff_t cache_timeout_ms,
struct curltime now)
static timediff_t dnscache_prune(struct Curl_hash *hostcache,
timediff_t cache_timeout_ms,
struct curltime now)
{
struct dnscache_prune_data user;
@ -389,11 +386,10 @@ static struct Curl_dns_entry *fetch_addr(struct Curl_easy *data,
* The returned data *MUST* be "released" with Curl_resolv_unlink() after
* use, or we will leak memory!
*/
struct Curl_dns_entry *
Curl_dnscache_get(struct Curl_easy *data,
const char *hostname,
int port,
int ip_version)
struct Curl_dns_entry *Curl_dnscache_get(struct Curl_easy *data,
const char *hostname,
int port,
int ip_version)
{
struct Curl_dnscache *dnscache = dnscache_get(data);
struct Curl_dns_entry *dns = NULL;
@ -447,7 +443,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
struct Curl_addrinfo **nodes;
infof(data, "Shuffling %i addresses", num_addrs);
nodes = curlx_malloc(num_addrs*sizeof(*nodes));
nodes = curlx_malloc(num_addrs * sizeof(*nodes));
if(nodes) {
int i;
unsigned int *rnd;
@ -456,7 +452,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
/* build a plain array of Curl_addrinfo pointers */
nodes[0] = *addr;
for(i = 1; i < num_addrs; i++) {
nodes[i] = nodes[i-1]->ai_next;
nodes[i] = nodes[i - 1]->ai_next;
}
rnd = curlx_malloc(rnd_size);
@ -472,10 +468,10 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
/* relink list in the new order */
for(i = 1; i < num_addrs; i++) {
nodes[i-1]->ai_next = nodes[i];
nodes[i - 1]->ai_next = nodes[i];
}
nodes[num_addrs-1]->ai_next = NULL;
nodes[num_addrs - 1]->ai_next = NULL;
*addr = nodes[0];
}
curlx_free(rnd);
@ -632,7 +628,7 @@ static struct Curl_addrinfo *get_localhost6(int port, const char *name)
return ca;
}
#else
#define get_localhost6(x,y) NULL
#define get_localhost6(x, y) NULL
#endif
/* return a static IPv4 127.0.0.1 for the given name */
@ -727,7 +723,6 @@ bool Curl_host_is_ipnum(const char *hostname)
return FALSE;
}
/* return TRUE if 'part' is a case insensitive tail of 'full' */
static bool tailmatch(const char *full, size_t flen,
const char *part, size_t plen)
@ -980,8 +975,7 @@ CURLcode Curl_resolv_blocking(struct Curl_easy *data,
* execution. This effectively causes the remainder of the application to run
* within a signal handler which is nonportable and could lead to problems.
*/
CURL_NORETURN static
void alarmfunc(int sig)
CURL_NORETURN static void alarmfunc(int sig)
{
(void)sig;
siglongjmp(curl_jmpenv, 1);
@ -1018,7 +1012,7 @@ CURLcode Curl_resolv_timeout(struct Curl_easy *data,
{
#ifdef USE_ALARM_TIMEOUT
#ifdef HAVE_SIGACTION
struct sigaction keep_sigact; /* store the old struct here */
struct sigaction keep_sigact; /* store the old struct here */
volatile bool keep_copysig = FALSE; /* whether old sigact has been saved */
struct sigaction sigact;
#else
@ -1058,8 +1052,8 @@ CURLcode Curl_resolv_timeout(struct Curl_easy *data,
/* The alarm() function only provides integer second resolution, so if
we want to wait less than one second we must bail out already now. */
failf(data,
"remaining timeout of %ld too small to resolve via SIGALRM method",
timeout);
"remaining timeout of %ld too small to resolve via SIGALRM method",
timeout);
return CURLE_OPERATION_TIMEDOUT;
}
/* This allows us to time-out from the name resolver, as the timeout
@ -1101,7 +1095,7 @@ CURLcode Curl_resolv_timeout(struct Curl_easy *data,
/* alarm() makes a signal get sent when the timeout fires off, and that
will abort system calls */
prev_alarm = alarm(curlx_sltoui(timeout/1000L));
prev_alarm = alarm(curlx_sltoui(timeout / 1000L));
}
#else /* !USE_ALARM_TIMEOUT */
@ -1151,7 +1145,7 @@ clean_up:
unsigned long alarm_set = (unsigned long)(prev_alarm - elapsed_secs);
if(!alarm_set ||
((alarm_set >= 0x80000000) && (prev_alarm < 0x80000000)) ) {
((alarm_set >= 0x80000000) && (prev_alarm < 0x80000000))) {
/* if the alarm time-left reached zero or turned "negative" (counted
with unsigned values), we should fire off a SIGALRM here, but we
will not, and zero would be to switch it off so we never set it to
@ -1203,7 +1197,7 @@ void Curl_resolv_unlink(struct Curl_easy *data, struct Curl_dns_entry **pdns)
static void dnscache_entry_dtor(void *entry)
{
struct Curl_dns_entry *dns = (struct Curl_dns_entry *) entry;
struct Curl_dns_entry *dns = (struct Curl_dns_entry *)entry;
DEBUGASSERT(dns && (dns->refcount > 0));
dns->refcount--;
if(dns->refcount == 0)
@ -1361,8 +1355,7 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
error = FALSE;
err:
if(error) {
failf(data, "Could not parse CURLOPT_RESOLVE entry '%s'",
hostp->data);
failf(data, "Could not parse CURLOPT_RESOLVE entry '%s'", hostp->data);
Curl_freeaddrinfo(head);
return CURLE_SETOPT_OPTION_SYNTAX;
}