mirror of
https://github.com/curl/curl.git
synced 2026-08-25 22:03:47 +03:00
tidy-up: make conditional checks more consistent
... remove '== NULL' and '!= 0' Closes #6912
This commit is contained in:
parent
19ea52da4d
commit
063d3f3b96
85 changed files with 282 additions and 283 deletions
|
|
@ -628,7 +628,7 @@ restart:
|
|||
rc = SSH_OK;
|
||||
else if(rc == SSH_AUTH_INFO) {
|
||||
nprompts = ssh_userauth_kbdint_getnprompts(sshc->ssh_session);
|
||||
if(nprompts != 0)
|
||||
if(nprompts)
|
||||
return SSH_ERROR;
|
||||
|
||||
sshc->kbd_state = 2;
|
||||
|
|
@ -958,7 +958,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
* Get the "home" directory
|
||||
*/
|
||||
sshc->homedir = sftp_canonicalize_path(sshc->sftp_session, ".");
|
||||
if(sshc->homedir == NULL) {
|
||||
if(!sshc->homedir) {
|
||||
MOVE_TO_ERROR_STATE(CURLE_COULDNT_CONNECT);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1033,7 +1033,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
case SSH_SFTP_QUOTE_SETSTAT:
|
||||
rc = sftp_setstat(sshc->sftp_session, sshc->quote_path2,
|
||||
sshc->quote_attrs);
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
Curl_safefree(sshc->quote_path2);
|
||||
failf(data, "Attempt to set SFTP stats failed: %s",
|
||||
|
|
@ -1052,7 +1052,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
case SSH_SFTP_QUOTE_SYMLINK:
|
||||
rc = sftp_symlink(sshc->sftp_session, sshc->quote_path2,
|
||||
sshc->quote_path1);
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
Curl_safefree(sshc->quote_path2);
|
||||
failf(data, "symlink command failed: %s",
|
||||
|
|
@ -1068,7 +1068,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
case SSH_SFTP_QUOTE_MKDIR:
|
||||
rc = sftp_mkdir(sshc->sftp_session, sshc->quote_path1,
|
||||
(mode_t)data->set.new_directory_perms);
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
failf(data, "mkdir command failed: %s",
|
||||
ssh_get_error(sshc->ssh_session));
|
||||
|
|
@ -1083,7 +1083,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
case SSH_SFTP_QUOTE_RENAME:
|
||||
rc = sftp_rename(sshc->sftp_session, sshc->quote_path1,
|
||||
sshc->quote_path2);
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
Curl_safefree(sshc->quote_path2);
|
||||
failf(data, "rename command failed: %s",
|
||||
|
|
@ -1098,7 +1098,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
|
||||
case SSH_SFTP_QUOTE_RMDIR:
|
||||
rc = sftp_rmdir(sshc->sftp_session, sshc->quote_path1);
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
failf(data, "rmdir command failed: %s",
|
||||
ssh_get_error(sshc->ssh_session));
|
||||
|
|
@ -1112,7 +1112,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
|
||||
case SSH_SFTP_QUOTE_UNLINK:
|
||||
rc = sftp_unlink(sshc->sftp_session, sshc->quote_path1);
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
failf(data, "rm command failed: %s",
|
||||
ssh_get_error(sshc->ssh_session));
|
||||
|
|
@ -1187,7 +1187,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
sftp_attributes attrs;
|
||||
|
||||
attrs = sftp_stat(sshc->sftp_session, protop->path);
|
||||
if(attrs != 0) {
|
||||
if(attrs) {
|
||||
data->info.filetime = attrs->mtime;
|
||||
sftp_attributes_free(attrs);
|
||||
}
|
||||
|
|
@ -1211,12 +1211,12 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
{
|
||||
int flags;
|
||||
|
||||
if(data->state.resume_from != 0) {
|
||||
if(data->state.resume_from) {
|
||||
sftp_attributes attrs;
|
||||
|
||||
if(data->state.resume_from < 0) {
|
||||
attrs = sftp_stat(sshc->sftp_session, protop->path);
|
||||
if(attrs != 0) {
|
||||
if(attrs) {
|
||||
curl_off_t size = attrs->size;
|
||||
if(size < 0) {
|
||||
failf(data, "Bad file size (%" CURL_FORMAT_CURL_OFF_T ")", size);
|
||||
|
|
@ -1317,7 +1317,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
}
|
||||
|
||||
rc = sftp_seek64(sshc->sftp_file, data->state.resume_from);
|
||||
if(rc != 0) {
|
||||
if(rc) {
|
||||
MOVE_TO_SFTP_CLOSE_STATE();
|
||||
break;
|
||||
}
|
||||
|
|
@ -1433,7 +1433,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
char *tmpLine;
|
||||
|
||||
tmpLine = aprintf("%s\n", sshc->readdir_filename);
|
||||
if(tmpLine == NULL) {
|
||||
if(!tmpLine) {
|
||||
state(data, SSH_SFTP_CLOSE);
|
||||
sshc->actualcode = CURLE_OUT_OF_MEMORY;
|
||||
break;
|
||||
|
|
@ -1472,7 +1472,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
sshc->readdir_linkPath = aprintf("%s%s", protop->path,
|
||||
sshc->readdir_filename);
|
||||
|
||||
if(sshc->readdir_linkPath == NULL) {
|
||||
if(!sshc->readdir_linkPath) {
|
||||
state(data, SSH_SFTP_CLOSE);
|
||||
sshc->actualcode = CURLE_OUT_OF_MEMORY;
|
||||
break;
|
||||
|
|
@ -1510,10 +1510,10 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
break;
|
||||
}
|
||||
|
||||
if(sshc->readdir_link_attrs->name == NULL) {
|
||||
if(!sshc->readdir_link_attrs->name) {
|
||||
sshc->readdir_tmp = sftp_readlink(sshc->sftp_session,
|
||||
sshc->readdir_linkPath);
|
||||
if(sshc->readdir_filename == NULL)
|
||||
if(!sshc->readdir_filename)
|
||||
sshc->readdir_len = 0;
|
||||
else
|
||||
sshc->readdir_len = strlen(sshc->readdir_tmp);
|
||||
|
|
@ -1679,7 +1679,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
}
|
||||
|
||||
rc = sftp_seek64(sshc->sftp_file, from);
|
||||
if(rc != 0) {
|
||||
if(rc) {
|
||||
MOVE_TO_SFTP_CLOSE_STATE();
|
||||
break;
|
||||
}
|
||||
|
|
@ -1718,7 +1718,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
size - data->state.resume_from);
|
||||
|
||||
rc = sftp_seek64(sshc->sftp_file, data->state.resume_from);
|
||||
if(rc != 0) {
|
||||
if(rc) {
|
||||
MOVE_TO_SFTP_CLOSE_STATE();
|
||||
break;
|
||||
}
|
||||
|
|
@ -2187,7 +2187,7 @@ static CURLcode myssh_connect(struct Curl_easy *data, bool *done)
|
|||
ssh = &conn->proto.sshc;
|
||||
|
||||
ssh->ssh_session = ssh_new();
|
||||
if(ssh->ssh_session == NULL) {
|
||||
if(!ssh->ssh_session) {
|
||||
failf(data, "Failure initialising ssh session");
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
|
|
@ -2685,7 +2685,7 @@ static void sftp_quote(struct Curl_easy *data)
|
|||
* command with a space so we can check for it unconditionally
|
||||
*/
|
||||
cp = strchr(cmd, ' ');
|
||||
if(cp == NULL) {
|
||||
if(!cp) {
|
||||
failf(data, "Syntax error in SFTP command. Supply parameter(s)!");
|
||||
state(data, SSH_SFTP_CLOSE);
|
||||
sshc->nextstate = SSH_NO_STATE;
|
||||
|
|
@ -2834,7 +2834,7 @@ static void sftp_quote_stat(struct Curl_easy *data)
|
|||
if(sshc->quote_attrs)
|
||||
sftp_attributes_free(sshc->quote_attrs);
|
||||
sshc->quote_attrs = sftp_stat(sshc->sftp_session, sshc->quote_path2);
|
||||
if(sshc->quote_attrs == NULL) {
|
||||
if(!sshc->quote_attrs) {
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
Curl_safefree(sshc->quote_path2);
|
||||
failf(data, "Attempt to get SFTP stats failed: %d",
|
||||
|
|
|
|||
|
|
@ -956,7 +956,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
out_of_memory = TRUE;
|
||||
}
|
||||
|
||||
if(out_of_memory || sshc->rsa == NULL) {
|
||||
if(out_of_memory || !sshc->rsa) {
|
||||
Curl_safefree(sshc->rsa);
|
||||
Curl_safefree(sshc->rsa_pub);
|
||||
state(data, SSH_SESSION_FREE);
|
||||
|
|
@ -1359,7 +1359,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
* command with a space so we can check for it unconditionally
|
||||
*/
|
||||
cp = strchr(cmd, ' ');
|
||||
if(cp == NULL) {
|
||||
if(!cp) {
|
||||
failf(data, "Syntax error command '%s'. Missing parameter!",
|
||||
cmd);
|
||||
state(data, SSH_SFTP_CLOSE);
|
||||
|
|
@ -1534,7 +1534,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
break;
|
||||
}
|
||||
if(rc != 0 && !sshc->acceptfail) { /* get those attributes */
|
||||
if(rc && !sshc->acceptfail) { /* get those attributes */
|
||||
sftperr = libssh2_sftp_last_error(sshc->sftp_session);
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
Curl_safefree(sshc->quote_path2);
|
||||
|
|
@ -1633,7 +1633,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
break;
|
||||
}
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
sftperr = libssh2_sftp_last_error(sshc->sftp_session);
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
Curl_safefree(sshc->quote_path2);
|
||||
|
|
@ -1656,7 +1656,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
break;
|
||||
}
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
sftperr = libssh2_sftp_last_error(sshc->sftp_session);
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
Curl_safefree(sshc->quote_path2);
|
||||
|
|
@ -1677,7 +1677,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
break;
|
||||
}
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
sftperr = libssh2_sftp_last_error(sshc->sftp_session);
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
failf(data, "mkdir command failed: %s",
|
||||
|
|
@ -1702,7 +1702,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
break;
|
||||
}
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
sftperr = libssh2_sftp_last_error(sshc->sftp_session);
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
Curl_safefree(sshc->quote_path2);
|
||||
|
|
@ -1722,7 +1722,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
break;
|
||||
}
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
sftperr = libssh2_sftp_last_error(sshc->sftp_session);
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
failf(data, "rmdir command failed: %s",
|
||||
|
|
@ -1741,7 +1741,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
break;
|
||||
}
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
sftperr = libssh2_sftp_last_error(sshc->sftp_session);
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
failf(data, "rm command failed: %s", sftp_libssh2_strerror(sftperr));
|
||||
|
|
@ -1764,7 +1764,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
break;
|
||||
}
|
||||
if(rc != 0 && !sshc->acceptfail) {
|
||||
if(rc && !sshc->acceptfail) {
|
||||
sftperr = libssh2_sftp_last_error(sshc->sftp_session);
|
||||
Curl_safefree(sshc->quote_path1);
|
||||
failf(data, "statvfs command failed: %s",
|
||||
|
|
@ -1857,7 +1857,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
* same name as the last directory in the path.
|
||||
*/
|
||||
|
||||
if(data->state.resume_from != 0) {
|
||||
if(data->state.resume_from) {
|
||||
LIBSSH2_SFTP_ATTRIBUTES attrs;
|
||||
if(data->state.resume_from < 0) {
|
||||
rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshp->path,
|
||||
|
|
@ -3084,7 +3084,7 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done)
|
|||
sshc->ssh_session = libssh2_session_init_ex(my_libssh2_malloc,
|
||||
my_libssh2_free,
|
||||
my_libssh2_realloc, data);
|
||||
if(sshc->ssh_session == NULL) {
|
||||
if(!sshc->ssh_session) {
|
||||
failf(data, "Failure initialising ssh session");
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ static CURLcode wssh_connect(struct Curl_easy *data, bool *done)
|
|||
}
|
||||
|
||||
sshc->ssh_session = wolfSSH_new(sshc->ctx);
|
||||
if(sshc->ssh_session == NULL) {
|
||||
if(!sshc->ssh_session) {
|
||||
failf(data, "No wolfSSH session");
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -861,7 +861,7 @@ static CURLcode wssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
char *line = aprintf("%s\n",
|
||||
data->set.list_only ?
|
||||
name->fName : name->lName);
|
||||
if(line == NULL) {
|
||||
if(!line) {
|
||||
state(data, SSH_SFTP_CLOSE);
|
||||
sshc->actualcode = CURLE_OUT_OF_MEMORY;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue