lib: refactor the type of funcs which have useless return and checks

Some internal functions always return CURLE_OK.

- Curl_http_proxy_get_destination() does that from bb4032a, (2 years
  ago) And the original inline code does not need to check the status.

- Curl_wildcard_init() does that from e60fe20. (8 years ago)

- Curl_initinfo() does that from a very beginning.

- Curl_pgrsSetDownloadCounter() did not have a return before 914e49b,
  ad051e1 recovered its content (2 years ago) but did not completely
  recovered the changes related to it.

- auth_digest_get_qop_values() does that from 676de7f.

This directly changes their type to void and cleaned the remaining
checks for their return value.

Closes #19386
This commit is contained in:
x2018
2025-11-07 01:59:00 +08:00
committed by Daniel Stenberg
parent 2684af257e
commit 608d96694b
13 changed files with 20 additions and 42 deletions

View File

@@ -87,7 +87,6 @@ static CURLcode tunnel_stream_init(struct Curl_cfilter *cf,
const char *hostname;
int port;
bool ipv6_ip;
CURLcode result;
ts->state = H2_TUNNEL_INIT;
ts->stream_id = -1;
@@ -95,9 +94,7 @@ static CURLcode tunnel_stream_init(struct Curl_cfilter *cf,
BUFQ_OPT_SOFT_LIMIT);
Curl_bufq_init(&ts->sendbuf, PROXY_H2_CHUNK_SIZE, H2_TUNNEL_SEND_CHUNKS);
result = Curl_http_proxy_get_destination(cf, &hostname, &port, &ipv6_ip);
if(result)
return result;
Curl_http_proxy_get_destination(cf, &hostname, &port, &ipv6_ip);
/* host:port with IPv6 support */
ts->authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[":"", hostname,

View File

@@ -185,12 +185,10 @@ static void fileinfo_dtor(void *user, void *element)
Curl_fileinfo_cleanup(element);
}
CURLcode Curl_wildcard_init(struct WildcardData *wc)
void Curl_wildcard_init(struct WildcardData *wc)
{
Curl_llist_init(&wc->filelist, fileinfo_dtor);
wc->state = CURLWC_INIT;
return CURLE_OK;
}
void Curl_wildcard_dtor(struct WildcardData **wcp)

View File

@@ -65,7 +65,7 @@ struct WildcardData {
unsigned char state; /* wildcard_states */
};
CURLcode Curl_wildcard_init(struct WildcardData *wc);
void Curl_wildcard_init(struct WildcardData *wc);
void Curl_wildcard_dtor(struct WildcardData **wcp);
struct Curl_easy;

View File

@@ -45,7 +45,7 @@
* beginning of a perform session. It must reset the session-info variables,
* in particular all variables in struct PureInfo.
*/
CURLcode Curl_initinfo(struct Curl_easy *data)
void Curl_initinfo(struct Curl_easy *data)
{
struct Progress *pro = &data->progress;
struct PureInfo *info = &data->info;
@@ -91,7 +91,6 @@ CURLcode Curl_initinfo(struct Curl_easy *data)
#ifdef USE_SSL
Curl_ssl_free_certinfo(data);
#endif
return CURLE_OK;
}
static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info,

View File

@@ -24,6 +24,6 @@
*
***************************************************************************/
CURLcode Curl_getinfo(struct Curl_easy *data, CURLINFO info, ...);
CURLcode Curl_initinfo(struct Curl_easy *data);
void Curl_initinfo(struct Curl_easy *data);
#endif /* HEADER_CURL_GETINFO_H */

View File

@@ -167,9 +167,9 @@ static CURLcode dynhds_add_custom(struct Curl_easy *data,
return CURLE_OK;
}
CURLcode Curl_http_proxy_get_destination(struct Curl_cfilter *cf,
const char **phostname,
int *pport, bool *pipv6_ip)
void Curl_http_proxy_get_destination(struct Curl_cfilter *cf,
const char **phostname,
int *pport, bool *pipv6_ip)
{
DEBUGASSERT(cf);
DEBUGASSERT(cf->conn);
@@ -192,8 +192,6 @@ CURLcode Curl_http_proxy_get_destination(struct Curl_cfilter *cf,
*pipv6_ip = (strchr(*phostname, ':') != NULL);
else
*pipv6_ip = cf->conn->bits.ipv6_ip;
return CURLE_OK;
}
struct cf_proxy_ctx {
@@ -214,9 +212,7 @@ CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq,
CURLcode result;
struct httpreq *req = NULL;
result = Curl_http_proxy_get_destination(cf, &hostname, &port, &ipv6_ip);
if(result)
goto out;
Curl_http_proxy_get_destination(cf, &hostname, &port, &ipv6_ip);
authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[" : "", hostname,
ipv6_ip ?"]" : "", port);

View File

@@ -36,9 +36,9 @@ enum Curl_proxy_use {
HEADER_CONNECT /* sending CONNECT to a proxy */
};
CURLcode Curl_http_proxy_get_destination(struct Curl_cfilter *cf,
const char **phostname,
int *pport, bool *pipv6_ip);
void Curl_http_proxy_get_destination(struct Curl_cfilter *cf,
const char **phostname,
int *pport, bool *pipv6_ip);
CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq,
struct Curl_cfilter *cf,

View File

@@ -305,10 +305,9 @@ timediff_t Curl_pgrsLimitWaitTime(struct pgrs_dir *d,
/*
* Set the number of downloaded bytes so far.
*/
CURLcode Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
{
data->progress.dl.cur_size = size;
return CURLE_OK;
}
/*

View File

@@ -48,9 +48,7 @@ void Curl_pgrsStartNow(struct Curl_easy *data);
void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size);
void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size);
/* It is fine to not check the return code if 'size' is set to 0 */
CURLcode Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size);
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size);
void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size);
void Curl_ratelimit(struct Curl_easy *data, struct curltime now);
int Curl_pgrsUpdate(struct Curl_easy *data);

View File

@@ -316,9 +316,7 @@ static CURLcode cw_download_write(struct Curl_easy *data,
}
/* Update stats, write and report progress */
data->req.bytecount += nwrite;
result = Curl_pgrsSetDownloadCounter(data, data->req.bytecount);
if(result)
return result;
Curl_pgrsSetDownloadCounter(data, data->req.bytecount);
if(excess_len) {
if(!data->req.ignorebody) {

View File

@@ -1599,9 +1599,8 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
}
total_dl += nread;
result = Curl_pgrsSetDownloadCounter(data, total_dl);
if(!result)
result = telrcv(data, tn, (unsigned char *)buffer, nread);
Curl_pgrsSetDownloadCounter(data, total_dl);
result = telrcv(data, tn, (unsigned char *)buffer, nread);
if(result) {
keepon = FALSE;
break;

View File

@@ -606,9 +606,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
wc->dtor(wc->ftpwc);
Curl_safefree(wc->pattern);
Curl_safefree(wc->path);
result = Curl_wildcard_init(wc); /* init wildcard structures */
if(result)
return CURLE_OUT_OF_MEMORY;
Curl_wildcard_init(wc); /* init wildcard structures */
}
}
#endif

View File

@@ -232,7 +232,7 @@ static bool auth_digest_get_key_value(const char *chlg, const char *key,
return FALSE;
}
static CURLcode auth_digest_get_qop_values(const char *options, int *value)
static void auth_digest_get_qop_values(const char *options, int *value)
{
struct Curl_str out;
/* Initialise the output */
@@ -248,8 +248,6 @@ static CURLcode auth_digest_get_qop_values(const char *options, int *value)
if(curlx_str_single(&options, ','))
break;
}
return CURLE_OK;
}
/*
@@ -377,9 +375,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
return CURLE_BAD_CONTENT_ENCODING;
/* Get the qop-values from the qop-options */
result = auth_digest_get_qop_values(qop_options, &qop_values);
if(result)
return result;
auth_digest_get_qop_values(qop_options, &qop_values);
/* We only support auth quality-of-protection */
if(!(qop_values & DIGEST_QOP_VALUE_AUTH))