lib: avoid assigning 'result' temporarily

Closes #15122
This commit is contained in:
Daniel Stenberg 2024-10-02 11:45:19 +02:00
parent 23386872d1
commit b5d453effa
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
5 changed files with 40 additions and 62 deletions

View File

@ -317,10 +317,8 @@ struct altsvcinfo *Curl_altsvc_init(void)
*/
CURLcode Curl_altsvc_load(struct altsvcinfo *asi, const char *file)
{
CURLcode result;
DEBUGASSERT(asi);
result = altsvc_load(asi, file);
return result;
return altsvc_load(asi, file);
}
/*

View File

@ -3916,8 +3916,7 @@ static CURLcode init_wc_data(struct Curl_easy *data)
last_slash++;
if(last_slash[0] == '\0') {
wildcard->state = CURLWC_CLEAN;
result = ftp_parse_url_path(data);
return result;
return ftp_parse_url_path(data);
}
wildcard->pattern = strdup(last_slash);
if(!wildcard->pattern)
@ -3933,8 +3932,7 @@ static CURLcode init_wc_data(struct Curl_easy *data)
}
else { /* only list */
wildcard->state = CURLWC_CLEAN;
result = ftp_parse_url_path(data);
return result;
return ftp_parse_url_path(data);
}
}

View File

@ -1974,11 +1974,8 @@ static CURLcode set_reader(struct Curl_easy *data, Curl_HttpReq httpreq)
switch(httpreq) {
case HTTPREQ_PUT: /* Let's PUT the data to the server! */
if(!postsize)
result = Curl_creader_set_null(data);
else
result = Curl_creader_set_fread(data, postsize);
return result;
return postsize ? Curl_creader_set_fread(data, postsize) :
Curl_creader_set_null(data);
#if !defined(CURL_DISABLE_MIME) || !defined(CURL_DISABLE_FORM_API)
case HTTPREQ_POST_FORM:

View File

@ -236,17 +236,13 @@ static CURLcode oldap_map_error(int rc, CURLcode result)
{
switch(rc) {
case LDAP_NO_MEMORY:
result = CURLE_OUT_OF_MEMORY;
break;
return CURLE_OUT_OF_MEMORY;
case LDAP_INVALID_CREDENTIALS:
result = CURLE_LOGIN_DENIED;
break;
return CURLE_LOGIN_DENIED;
case LDAP_PROTOCOL_ERROR:
result = CURLE_UNSUPPORTED_PROTOCOL;
break;
return CURLE_UNSUPPORTED_PROTOCOL;
case LDAP_INSUFFICIENT_ACCESS:
result = CURLE_REMOTE_ACCESS_DENIED;
break;
return CURLE_REMOTE_ACCESS_DENIED;
}
return result;
}
@ -352,7 +348,6 @@ static CURLcode oldap_perform_auth(struct Curl_easy *data, const char *mech,
{
struct connectdata *conn = data->conn;
struct ldapconninfo *li = conn->proto.ldapc;
CURLcode result = CURLE_OK;
struct berval cred;
struct berval *pcred = &cred;
int rc;
@ -363,8 +358,8 @@ static CURLcode oldap_perform_auth(struct Curl_easy *data, const char *mech,
pcred = NULL;
rc = ldap_sasl_bind(li->ld, NULL, mech, pcred, NULL, NULL, &li->msgid);
if(rc != LDAP_SUCCESS)
result = oldap_map_error(rc, CURLE_LDAP_CANNOT_BIND);
return result;
return oldap_map_error(rc, CURLE_LDAP_CANNOT_BIND);
return CURLE_OK;
}
/*
@ -375,7 +370,6 @@ static CURLcode oldap_continue_auth(struct Curl_easy *data, const char *mech,
{
struct connectdata *conn = data->conn;
struct ldapconninfo *li = conn->proto.ldapc;
CURLcode result = CURLE_OK;
struct berval cred;
struct berval *pcred = &cred;
int rc;
@ -386,8 +380,8 @@ static CURLcode oldap_continue_auth(struct Curl_easy *data, const char *mech,
pcred = NULL;
rc = ldap_sasl_bind(li->ld, NULL, mech, pcred, NULL, NULL, &li->msgid);
if(rc != LDAP_SUCCESS)
result = oldap_map_error(rc, CURLE_LDAP_CANNOT_BIND);
return result;
return oldap_map_error(rc, CURLE_LDAP_CANNOT_BIND);
return CURLE_OK;
}
/*
@ -396,20 +390,18 @@ static CURLcode oldap_continue_auth(struct Curl_easy *data, const char *mech,
static CURLcode oldap_cancel_auth(struct Curl_easy *data, const char *mech)
{
struct ldapconninfo *li = data->conn->proto.ldapc;
CURLcode result = CURLE_OK;
int rc = ldap_sasl_bind(li->ld, NULL, LDAP_SASL_NULL, NULL, NULL, NULL,
&li->msgid);
(void)mech;
if(rc != LDAP_SUCCESS)
result = oldap_map_error(rc, CURLE_LDAP_CANNOT_BIND);
return result;
return oldap_map_error(rc, CURLE_LDAP_CANNOT_BIND);
return CURLE_OK;
}
/* Starts LDAP simple bind. */
static CURLcode oldap_perform_bind(struct Curl_easy *data, ldapstate newstate)
{
CURLcode result = CURLE_OK;
struct connectdata *conn = data->conn;
struct ldapconninfo *li = conn->proto.ldapc;
char *binddn = NULL;
@ -427,19 +419,17 @@ static CURLcode oldap_perform_bind(struct Curl_easy *data, ldapstate newstate)
rc = ldap_sasl_bind(li->ld, binddn, LDAP_SASL_SIMPLE, &passwd,
NULL, NULL, &li->msgid);
if(rc == LDAP_SUCCESS)
oldap_state(data, newstate);
else
result = oldap_map_error(rc,
data->state.aptr.user ?
CURLE_LOGIN_DENIED : CURLE_LDAP_CANNOT_BIND);
return result;
if(rc != LDAP_SUCCESS)
return oldap_map_error(rc,
data->state.aptr.user ?
CURLE_LOGIN_DENIED : CURLE_LDAP_CANNOT_BIND);
oldap_state(data, newstate);
return CURLE_OK;
}
/* Query the supported SASL authentication mechanisms. */
static CURLcode oldap_perform_mechs(struct Curl_easy *data)
{
CURLcode result = CURLE_OK;
struct ldapconninfo *li = data->conn->proto.ldapc;
int rc;
static const char * const supportedSASLMechanisms[] = {
@ -450,11 +440,10 @@ static CURLcode oldap_perform_mechs(struct Curl_easy *data)
rc = ldap_search_ext(li->ld, "", LDAP_SCOPE_BASE, "(objectclass=*)",
(char **) supportedSASLMechanisms, 0,
NULL, NULL, NULL, 0, &li->msgid);
if(rc == LDAP_SUCCESS)
oldap_state(data, OLDAP_MECHS);
else
result = oldap_map_error(rc, CURLE_LOGIN_DENIED);
return result;
if(rc != LDAP_SUCCESS)
return oldap_map_error(rc, CURLE_LOGIN_DENIED);
oldap_state(data, OLDAP_MECHS);
return CURLE_OK;
}
/* Starts SASL bind. */
@ -480,12 +469,11 @@ static bool ssl_installed(struct connectdata *conn)
static CURLcode oldap_ssl_connect(struct Curl_easy *data, ldapstate newstate)
{
CURLcode result = CURLE_OK;
struct connectdata *conn = data->conn;
struct ldapconninfo *li = conn->proto.ldapc;
bool ssldone = 0;
result = Curl_conn_connect(data, FIRSTSOCKET, FALSE, &ssldone);
CURLcode result =
Curl_conn_connect(data, FIRSTSOCKET, FALSE, &ssldone);
if(!result) {
oldap_state(data, newstate);
@ -506,15 +494,13 @@ static CURLcode oldap_ssl_connect(struct Curl_easy *data, ldapstate newstate)
/* Send the STARTTLS request */
static CURLcode oldap_perform_starttls(struct Curl_easy *data)
{
CURLcode result = CURLE_OK;
struct ldapconninfo *li = data->conn->proto.ldapc;
int rc = ldap_start_tls(li->ld, NULL, NULL, &li->msgid);
if(rc == LDAP_SUCCESS)
oldap_state(data, OLDAP_STARTTLS);
else
result = oldap_map_error(rc, CURLE_USE_SSL_FAILED);
return result;
if(rc != LDAP_SUCCESS)
return oldap_map_error(rc, CURLE_USE_SSL_FAILED);
oldap_state(data, OLDAP_STARTTLS);
return CURLE_OK;
}
#endif

View File

@ -3205,22 +3205,21 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
plen = strlen(argptr);
if(plen > CURL_MAX_INPUT_LENGTH) {
data->set.tls_ech = CURLECH_DISABLE;
result = CURLE_BAD_FUNCTION_ARGUMENT;
return result;
return CURLE_BAD_FUNCTION_ARGUMENT;
}
/* set tls_ech flag value, preserving CLA_CFG bit */
if(plen == 5 && !strcmp(argptr, "false"))
data->set.tls_ech = CURLECH_DISABLE
| (data->set.tls_ech & CURLECH_CLA_CFG);
data->set.tls_ech = CURLECH_DISABLE |
(data->set.tls_ech & CURLECH_CLA_CFG);
else if(plen == 6 && !strcmp(argptr, "grease"))
data->set.tls_ech = CURLECH_GREASE
| (data->set.tls_ech & CURLECH_CLA_CFG);
data->set.tls_ech = CURLECH_GREASE |
(data->set.tls_ech & CURLECH_CLA_CFG);
else if(plen == 4 && !strcmp(argptr, "true"))
data->set.tls_ech = CURLECH_ENABLE
| (data->set.tls_ech & CURLECH_CLA_CFG);
data->set.tls_ech = CURLECH_ENABLE |
(data->set.tls_ech & CURLECH_CLA_CFG);
else if(plen == 4 && !strcmp(argptr, "hard"))
data->set.tls_ech = CURLECH_HARD
| (data->set.tls_ech & CURLECH_CLA_CFG);
data->set.tls_ech = CURLECH_HARD |
(data->set.tls_ech & CURLECH_CLA_CFG);
else if(plen > 5 && !strncmp(argptr, "ecl:", 4)) {
result = Curl_setstropt(&data->set.str[STRING_ECH_CONFIG], argptr + 4);
if(result)