pgbackrest.git / summary / log / commit / refs

commit    e280ed9098a6f5da9bdabb541e9c69d4f24ffcf2
Author:   David Steele <david@pgmasters.net>
Date:     Thu Jul 06 06:58:16 2023 +0000

    Make result code handling in storage/sftp more consistent.
    
    Initializers are useless since rc is always set later. Make rc checks consistent with the rest of the module.


src/storage/sftp/read.c | 4 ++-- src/storage/sftp/write.c | 8 ++++---- test/src/common/harnessLibSsh2.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/storage/sftp/read.c b/src/storage/sftp/read.c index 17285cfb1..8c8e39a20 100644 --- a/src/storage/sftp/read.c +++ b/src/storage/sftp/read.c @@ -193,7 +193,7 @@ storageReadSftpClose(THIS_VOID) if (this->sftpHandle != NULL) { - int rc = 0; + int rc; Wait *const wait = waitNew(this->timeout); // Close the file @@ -205,7 +205,7 @@ storageReadSftpClose(THIS_VOID) waitFree(wait); - if (rc) + if (rc != 0) { THROW_FMT( FileCloseError, diff --git a/src/storage/sftp/write.c b/src/storage/sftp/write.c index 3eb456477..17fb5a9af 100644 --- a/src/storage/sftp/write.c +++ b/src/storage/sftp/write.c @@ -189,7 +189,7 @@ storageWriteSftpUnlinkExisting(THIS_VOID) waitFree(wait); - if (rc) + if (rc != 0) { storageSftpEvalLibSsh2Error( rc, libssh2_sftp_last_error(this->sftpSession), &FileRemoveError, @@ -227,7 +227,7 @@ storageWriteSftpRename(THIS_VOID) waitFree(wait); - if (rc) + if (rc != 0) { storageSftpEvalLibSsh2Error( rc, libssh2_sftp_last_error(this->sftpSession), &FileRemoveError, @@ -271,7 +271,7 @@ storageWriteSftpClose(THIS_VOID) waitFree(wait); - if (rc) + if (rc != 0) THROW_FMT(FileSyncError, STORAGE_ERROR_WRITE_SYNC, strZ(this->nameTmp)); } @@ -313,7 +313,7 @@ storageWriteSftpClose(THIS_VOID) waitFree(wait); - if (rc) + if (rc != 0) { // Some/most sftp servers will not rename over an existing file, in testing this returned LIBSSH2_FX_FAILURE if (rc == LIBSSH2_ERROR_SFTP_PROTOCOL && libssh2_sftp_last_error(this->sftpSession) == LIBSSH2_FX_FAILURE) diff --git a/test/src/common/harnessLibSsh2.c b/test/src/common/harnessLibSsh2.c index 3885ee38c..9f7361214 100644 --- a/test/src/common/harnessLibSsh2.c +++ b/test/src/common/harnessLibSsh2.c @@ -424,7 +424,7 @@ libssh2_sftp_symlink_ex( } MEM_CONTEXT_TEMP_END(); - int rc = 0; + int rc; switch (link_type) { [parent: 1fd8845c7ffd]