diff options
author | Simon Tatham <anakin@pobox.com> | 2022-09-04 12:54:34 +0300 |
---|---|---|
committer | Simon Tatham <anakin@pobox.com> | 2022-09-04 13:19:13 +0300 |
commit | 9e7d4c53d80b6ebb9598610ab706faf2218c8a7b (patch) | |
tree | cfb5e06bdce7d0ce8bfd66821ad07c4110030770 /psftp.c | |
parent | 26f220a1a0b095336af61af6c5bfac5d4f038ddc (diff) |
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.
Diffstat (limited to 'psftp.c')
-rw-r--r-- | psftp.c | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -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; } |