url: make Curl_init_userdefined return void

It cannot actually return an error, so the parent function does not need
to check for error and have an exit path that cannot be reached.

Pointed out by CodeSonar

Closes #18855
This commit is contained in:
Daniel Stenberg 2025-10-05 14:07:39 +02:00
parent 1ae5e44eff
commit b54b4697ca
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 6 additions and 24 deletions

View file

@ -1110,7 +1110,7 @@ void curl_easy_reset(CURL *d)
/* zero out UserDefined data: */
Curl_freeset(data);
memset(&data->set, 0, sizeof(struct UserDefined));
(void)Curl_init_userdefined(data);
Curl_init_userdefined(data);
/* zero out Progress data: */
memset(&data->progress, 0, sizeof(struct Progress));

View file

@ -355,10 +355,9 @@ CURLcode Curl_close(struct Curl_easy **datap)
* Initialize the UserDefined fields within a Curl_easy.
* This may be safely called on a new or existing Curl_easy.
*/
CURLcode Curl_init_userdefined(struct Curl_easy *data)
void Curl_init_userdefined(struct Curl_easy *data)
{
struct UserDefined *set = &data->set;
CURLcode result = CURLE_OK;
set->out = stdout; /* default output to stdout */
set->in_set = stdin; /* default input from stdin */
@ -476,8 +475,6 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
set->ws_raw_mode = FALSE;
set->ws_no_auto_pong = FALSE;
#endif
return result;
}
/* easy->meta_hash destructor. Should never be called as elements
@ -501,7 +498,6 @@ static void easy_meta_freeentry(void *p)
CURLcode Curl_open(struct Curl_easy **curl)
{
CURLcode result;
struct Curl_easy *data;
/* simple start-up: alloc the struct, init it with zeroes and return */
@ -532,21 +528,10 @@ CURLcode Curl_open(struct Curl_easy **curl)
Curl_llist_init(&data->state.httphdrs, NULL);
#endif
Curl_netrc_init(&data->state.netrc);
Curl_init_userdefined(data);
result = Curl_init_userdefined(data);
if(result) {
curlx_dyn_free(&data->state.headerb);
Curl_freeset(data);
Curl_req_free(&data->req, data);
Curl_hash_destroy(&data->meta_hash);
data->magic = 0;
free(data);
data = NULL;
}
else
*curl = data;
return result;
*curl = data;
return CURLE_OK;
}
void Curl_conn_free(struct Curl_easy *data, struct connectdata *conn)

View file

@ -31,7 +31,7 @@
CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn);
CURLcode Curl_open(struct Curl_easy **curl);
CURLcode Curl_init_userdefined(struct Curl_easy *data);
void Curl_init_userdefined(struct Curl_easy *data);
void Curl_freeset(struct Curl_easy *data);
CURLcode Curl_uc_to_curlcode(CURLUcode uc);

View file

@ -97,9 +97,6 @@ static CURLcode test_unit1620(const char *arg)
fail_unless(rc == CURLE_URL_MALFORMAT,
"Curl_connect() failed to return CURLE_URL_MALFORMAT");
rc = Curl_init_userdefined(empty);
fail_unless(rc == CURLE_OK, "Curl_userdefined() failed");
rc = Curl_init_do(empty, empty->conn);
fail_unless(rc == CURLE_OK, "Curl_init_do() failed");