mirror of
https://github.com/curl/curl.git
synced 2026-08-25 15:33:39 +03:00
build: fix Codacy warnings
Reduce variable scopes and remove redundant variable stores. Closes https://github.com/curl/curl/pull/3975
This commit is contained in:
parent
04ac54e196
commit
e23c52b329
23 changed files with 80 additions and 123 deletions
|
|
@ -218,7 +218,6 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out,
|
|||
const unsigned char *key_56)
|
||||
{
|
||||
const CK_MECHANISM_TYPE mech = CKM_DES_ECB; /* DES cipher in ECB mode */
|
||||
PK11SlotInfo *slot = NULL;
|
||||
char key[8]; /* expanded 64 bit key */
|
||||
SECItem key_item;
|
||||
PK11SymKey *symkey = NULL;
|
||||
|
|
@ -228,7 +227,7 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out,
|
|||
bool rv = FALSE;
|
||||
|
||||
/* use internal slot for DES encryption (requires NSS to be initialized) */
|
||||
slot = PK11_GetInternalKeySlot();
|
||||
PK11SlotInfo *slot = PK11_GetInternalKeySlot();
|
||||
if(!slot)
|
||||
return FALSE;
|
||||
|
||||
|
|
|
|||
18
lib/ftp.c
18
lib/ftp.c
|
|
@ -565,10 +565,8 @@ static CURLcode ftp_readresp(curl_socket_t sockfd,
|
|||
#ifdef HAVE_GSSAPI
|
||||
char * const buf = data->state.buffer;
|
||||
#endif
|
||||
CURLcode result = CURLE_OK;
|
||||
int code;
|
||||
|
||||
result = Curl_pp_readresp(sockfd, pp, &code, size);
|
||||
CURLcode result = Curl_pp_readresp(sockfd, pp, &code, size);
|
||||
|
||||
#if defined(HAVE_GSSAPI)
|
||||
/* handle the security-oriented responses 6xx ***/
|
||||
|
|
@ -1499,24 +1497,14 @@ static CURLcode ftp_state_list(struct connectdata *conn)
|
|||
|
||||
static CURLcode ftp_state_retr_prequote(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
/* We've sent the TYPE, now we must send the list of prequote strings */
|
||||
|
||||
result = ftp_state_quote(conn, TRUE, FTP_RETR_PREQUOTE);
|
||||
|
||||
return result;
|
||||
return ftp_state_quote(conn, TRUE, FTP_RETR_PREQUOTE);
|
||||
}
|
||||
|
||||
static CURLcode ftp_state_stor_prequote(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
/* We've sent the TYPE, now we must send the list of prequote strings */
|
||||
|
||||
result = ftp_state_quote(conn, TRUE, FTP_STOR_PREQUOTE);
|
||||
|
||||
return result;
|
||||
return ftp_state_quote(conn, TRUE, FTP_STOR_PREQUOTE);
|
||||
}
|
||||
|
||||
static CURLcode ftp_state_type(struct connectdata *conn)
|
||||
|
|
|
|||
15
lib/imap.c
15
lib/imap.c
|
|
@ -444,10 +444,8 @@ static CURLcode imap_perform_capability(struct connectdata *conn)
|
|||
*/
|
||||
static CURLcode imap_perform_starttls(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
/* Send the STARTTLS command */
|
||||
result = imap_sendf(conn, "STARTTLS");
|
||||
CURLcode result = imap_sendf(conn, "STARTTLS");
|
||||
|
||||
if(!result)
|
||||
state(conn, IMAP_STARTTLS);
|
||||
|
|
@ -463,11 +461,10 @@ static CURLcode imap_perform_starttls(struct connectdata *conn)
|
|||
*/
|
||||
static CURLcode imap_perform_upgrade_tls(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct imap_conn *imapc = &conn->proto.imapc;
|
||||
|
||||
/* Start the SSL connection */
|
||||
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone);
|
||||
struct imap_conn *imapc = &conn->proto.imapc;
|
||||
CURLcode result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET,
|
||||
&imapc->ssldone);
|
||||
|
||||
if(!result) {
|
||||
if(imapc->state != IMAP_UPGRADETLS)
|
||||
|
|
@ -826,10 +823,8 @@ static CURLcode imap_perform_search(struct connectdata *conn)
|
|||
*/
|
||||
static CURLcode imap_perform_logout(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
/* Send the LOGOUT command */
|
||||
result = imap_sendf(conn, "LOGOUT");
|
||||
CURLcode result = imap_sendf(conn, "LOGOUT");
|
||||
|
||||
if(!result)
|
||||
state(conn, IMAP_LOGOUT);
|
||||
|
|
|
|||
15
lib/pop3.c
15
lib/pop3.c
|
|
@ -339,10 +339,8 @@ static CURLcode pop3_perform_capa(struct connectdata *conn)
|
|||
*/
|
||||
static CURLcode pop3_perform_starttls(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
/* Send the STLS command */
|
||||
result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", "STLS");
|
||||
CURLcode result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", "STLS");
|
||||
|
||||
if(!result)
|
||||
state(conn, POP3_STARTTLS);
|
||||
|
|
@ -358,11 +356,10 @@ static CURLcode pop3_perform_starttls(struct connectdata *conn)
|
|||
*/
|
||||
static CURLcode pop3_perform_upgrade_tls(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
|
||||
/* Start the SSL connection */
|
||||
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &pop3c->ssldone);
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
CURLcode result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET,
|
||||
&pop3c->ssldone);
|
||||
|
||||
if(!result) {
|
||||
if(pop3c->state != POP3_UPGRADETLS)
|
||||
|
|
@ -593,10 +590,8 @@ static CURLcode pop3_perform_command(struct connectdata *conn)
|
|||
*/
|
||||
static CURLcode pop3_perform_quit(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
/* Send the QUIT command */
|
||||
result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", "QUIT");
|
||||
CURLcode result = Curl_pp_sendf(&conn->proto.pop3c.pp, "%s", "QUIT");
|
||||
|
||||
if(!result)
|
||||
state(conn, POP3_QUIT);
|
||||
|
|
|
|||
|
|
@ -957,7 +957,6 @@ static CURLcode smb_do(struct connectdata *conn, bool *done)
|
|||
|
||||
static CURLcode smb_parse_url_path(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct Curl_easy *data = conn->data;
|
||||
struct smb_request *req = data->req.protop;
|
||||
struct smb_conn *smbc = &conn->proto.smbc;
|
||||
|
|
@ -965,7 +964,8 @@ static CURLcode smb_parse_url_path(struct connectdata *conn)
|
|||
char *slash;
|
||||
|
||||
/* URL decode the path */
|
||||
result = Curl_urldecode(data, data->state.up.path, 0, &path, NULL, TRUE);
|
||||
CURLcode result = Curl_urldecode(data, data->state.up.path, 0, &path, NULL,
|
||||
TRUE);
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
|
|
|
|||
15
lib/smtp.c
15
lib/smtp.c
|
|
@ -359,10 +359,8 @@ static CURLcode smtp_perform_helo(struct connectdata *conn)
|
|||
*/
|
||||
static CURLcode smtp_perform_starttls(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
/* Send the STARTTLS command */
|
||||
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "STARTTLS");
|
||||
CURLcode result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "STARTTLS");
|
||||
|
||||
if(!result)
|
||||
state(conn, SMTP_STARTTLS);
|
||||
|
|
@ -378,11 +376,10 @@ static CURLcode smtp_perform_starttls(struct connectdata *conn)
|
|||
*/
|
||||
static CURLcode smtp_perform_upgrade_tls(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct smtp_conn *smtpc = &conn->proto.smtpc;
|
||||
|
||||
/* Start the SSL connection */
|
||||
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &smtpc->ssldone);
|
||||
struct smtp_conn *smtpc = &conn->proto.smtpc;
|
||||
CURLcode result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET,
|
||||
&smtpc->ssldone);
|
||||
|
||||
if(!result) {
|
||||
if(smtpc->state != SMTP_UPGRADETLS)
|
||||
|
|
@ -645,10 +642,8 @@ static CURLcode smtp_perform_rcpt_to(struct connectdata *conn)
|
|||
*/
|
||||
static CURLcode smtp_perform_quit(struct connectdata *conn)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
/* Send the QUIT command */
|
||||
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "QUIT");
|
||||
CURLcode result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "QUIT");
|
||||
|
||||
if(!result)
|
||||
state(conn, SMTP_QUIT);
|
||||
|
|
|
|||
|
|
@ -1968,11 +1968,10 @@ static CURLcode myssh_multi_statemach(struct connectdata *conn,
|
|||
bool *done)
|
||||
{
|
||||
struct ssh_conn *sshc = &conn->proto.sshc;
|
||||
CURLcode result = CURLE_OK;
|
||||
bool block; /* we store the status and use that to provide a ssh_getsock()
|
||||
implementation */
|
||||
CURLcode result = myssh_statemach_act(conn, &block);
|
||||
|
||||
result = myssh_statemach_act(conn, &block);
|
||||
*done = (sshc->state == SSH_STOP) ? TRUE : FALSE;
|
||||
myssh_block2waitfor(conn, block);
|
||||
|
||||
|
|
|
|||
|
|
@ -357,7 +357,6 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
|
|||
const char *service,
|
||||
char **outptr, size_t *outlen)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
size_t i;
|
||||
MD5_context *ctxt;
|
||||
char *response = NULL;
|
||||
|
|
@ -377,10 +376,12 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
|
|||
char *spn = NULL;
|
||||
|
||||
/* Decode the challenge message */
|
||||
result = auth_decode_digest_md5_message(chlg64, nonce, sizeof(nonce),
|
||||
realm, sizeof(realm),
|
||||
algorithm, sizeof(algorithm),
|
||||
qop_options, sizeof(qop_options));
|
||||
CURLcode result = auth_decode_digest_md5_message(chlg64, nonce,
|
||||
sizeof(nonce), realm,
|
||||
sizeof(realm), algorithm,
|
||||
sizeof(algorithm),
|
||||
qop_options,
|
||||
sizeof(qop_options));
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
|
|
|
|||
|
|
@ -357,9 +357,8 @@ cyassl_connect_step1(struct connectdata *conn,
|
|||
|
||||
/* give application a chance to interfere with SSL set up. */
|
||||
if(data->set.ssl.fsslctx) {
|
||||
CURLcode result = CURLE_OK;
|
||||
result = (*data->set.ssl.fsslctx)(data, BACKEND->ctx,
|
||||
data->set.ssl.fsslctxp);
|
||||
CURLcode result = (*data->set.ssl.fsslctx)(data, BACKEND->ctx,
|
||||
data->set.ssl.fsslctxp);
|
||||
if(result) {
|
||||
failf(data, "error signaled by ssl ctx callback");
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -265,7 +265,6 @@ mesalink_connect_step2(struct connectdata *conn, int sockindex)
|
|||
|
||||
ret = SSL_connect(BACKEND->handle);
|
||||
if(ret != SSL_SUCCESS) {
|
||||
char error_buffer[MESALINK_MAX_ERROR_SZ];
|
||||
int detail = SSL_get_error(BACKEND->handle, ret);
|
||||
|
||||
if(SSL_ERROR_WANT_CONNECT == detail || SSL_ERROR_WANT_READ == detail) {
|
||||
|
|
@ -273,6 +272,7 @@ mesalink_connect_step2(struct connectdata *conn, int sockindex)
|
|||
return CURLE_OK;
|
||||
}
|
||||
else {
|
||||
char error_buffer[MESALINK_MAX_ERROR_SZ];
|
||||
failf(data,
|
||||
"SSL_connect failed with error %d: %s",
|
||||
detail,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue