1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Remove/rescope variable 'ret' in sftp_put_file.

This is a purely stylistic cleanup - no functional change intended -
after Tim Kosse's changes in commits e9a76883a and 6f871e3d2.

I think the underlying cause of the confusion whose functional effects
he was fixing there is that I have the bad habit of tending to call
variables 'ret' for two different reasons: one is because it's holding
the value returned from some subroutine I've just called, and the
other is because it's holding the value I'm preparing to return from
the routine _containing_ the variable.

The reason it's a bad habit is that I confuse the two purposes, and a
variable of one type ends up accidentally being treated as the other.
So while Tim's commits have already fixed the functional effects of
the error in this case, this change should help prevent a recurrence
because now there's no variable called 'ret' at all that's in scope
for the whole function.
This commit is contained in:
Simon Tatham 2016-12-29 11:25:34 +00:00
parent fa38307244
commit 86ba2e6339

View File

@ -491,7 +491,7 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart)
struct sftp_request *req;
uint64 offset;
RFile *file;
int ret, err = 0, eof;
int err = 0, eof;
struct fxp_attrs attrs;
long permissions;
@ -644,6 +644,7 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart)
if (restart) {
char decbuf[30];
struct fxp_attrs attrs;
int ret;
req = fxp_fstat_send(fh);
pktin = sftp_wait_for_reply(req);
@ -712,8 +713,7 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart)
cleanup:
req = fxp_close_send(fh);
pktin = sftp_wait_for_reply(req);
ret = fxp_close_recv(pktin, req);
if (!ret) {
if (!fxp_close_recv(pktin, req)) {
if (!err) {
printf("error while closing: %s", fxp_error());
err = 1;