mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 01:18:00 +00:00
Rename confusing variables in psftp_main().
Another of this weekend's warnings pointed out that this function contained a pattern I now regard as a cardinal sin: variables called 'ret' that aren't clear whether they've _been_ returned from a subroutine, or whether they're _planned_ to be returned from the containing function. Worse, psftp_main had both: two of the former kind shadowing a case of the latter in sub-scopes.
This commit is contained in:
parent
26f220a1a0
commit
9e7d4c53d8
23
psftp.c
23
psftp.c
@ -2790,7 +2790,7 @@ const unsigned cmdline_tooltype = TOOLTYPE_FILETRANSFER;
|
||||
*/
|
||||
int psftp_main(int argc, char *argv[])
|
||||
{
|
||||
int i, ret;
|
||||
int i, toret;
|
||||
int portnumber = 0;
|
||||
char *userhost, *user;
|
||||
int mode = 0;
|
||||
@ -2807,7 +2807,7 @@ int psftp_main(int argc, char *argv[])
|
||||
do_defaults(NULL, conf);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
int ret;
|
||||
int retd;
|
||||
if (argv[i][0] != '-') {
|
||||
if (userhost)
|
||||
usage();
|
||||
@ -2815,12 +2815,13 @@ int psftp_main(int argc, char *argv[])
|
||||
userhost = dupstr(argv[i]);
|
||||
continue;
|
||||
}
|
||||
ret = cmdline_process_param(argv[i], i+1<argc?argv[i+1]:NULL, 1, conf);
|
||||
if (ret == -2) {
|
||||
retd = cmdline_process_param(
|
||||
argv[i], i+1 < argc ? argv[i+1] : NULL, 1, conf);
|
||||
if (retd == -2) {
|
||||
cmdline_error("option \"%s\" requires an argument", argv[i]);
|
||||
} else if (ret == 2) {
|
||||
} else if (retd == 2) {
|
||||
i++; /* skip next argument */
|
||||
} else if (ret == 1) {
|
||||
} else if (retd == 1) {
|
||||
/* We have our own verbosity in addition to `flags'. */
|
||||
if (cmdline_verbose())
|
||||
verbose = true;
|
||||
@ -2881,10 +2882,10 @@ int psftp_main(int argc, char *argv[])
|
||||
* it now.
|
||||
*/
|
||||
if (userhost) {
|
||||
int ret;
|
||||
ret = psftp_connect(userhost, user, portnumber);
|
||||
int retd;
|
||||
retd = psftp_connect(userhost, user, portnumber);
|
||||
sfree(userhost);
|
||||
if (ret)
|
||||
if (retd)
|
||||
return 1;
|
||||
if (do_sftp_init())
|
||||
return 1;
|
||||
@ -2893,7 +2894,7 @@ int psftp_main(int argc, char *argv[])
|
||||
" to connect\n");
|
||||
}
|
||||
|
||||
ret = do_sftp(mode, modeflags, batchfile);
|
||||
toret = do_sftp(mode, modeflags, batchfile);
|
||||
|
||||
if (backend && backend_connected(backend)) {
|
||||
char ch;
|
||||
@ -2912,5 +2913,5 @@ int psftp_main(int argc, char *argv[])
|
||||
if (psftp_logctx)
|
||||
log_free(psftp_logctx);
|
||||
|
||||
return ret;
|
||||
return toret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user