]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Avoid a call to SMBC_errno()
authorVolker Lendecke <vl@samba.org>
Fri, 21 Jan 2022 19:21:17 +0000 (20:21 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 7 Feb 2022 19:00:34 +0000 (19:00 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/libsmb_file.c

index 2b45faef0aee4a1ea58183a838f56ca27e9849ad..d90d71134a888068df5bc9319d2914ea0908a48c 100644 (file)
@@ -402,6 +402,7 @@ SMBC_close_ctx(SMBCCTX *context,
                SMBCFILE *file)
 {
        TALLOC_CTX *frame = talloc_stackframe();
+       NTSTATUS status;
 
        if (!context || !context->internal->initialized) {
                errno = EINVAL;
@@ -421,19 +422,20 @@ SMBC_close_ctx(SMBCCTX *context,
                return smbc_getFunctionClosedir(context)(context, file);
        }
 
-       if (!NT_STATUS_IS_OK(cli_close(file->targetcli, file->cli_fd))) {
+       status = cli_close(file->targetcli, file->cli_fd);
+       if (!NT_STATUS_IS_OK(status)) {
                SMBCSRV *srv;
                DEBUG(3, ("cli_close failed on %s. purging server.\n",
                          file->fname));
                /* Deallocate slot and remove the server
                 * from the server cache if unused */
-               errno = SMBC_errno(context, file->targetcli);
                srv = file->srv;
                DLIST_REMOVE(context->internal->files, file);
                SAFE_FREE(file->fname);
                SAFE_FREE(file);
                smbc_getFunctionRemoveUnusedServer(context)(context, srv);
                TALLOC_FREE(frame);
+               errno = cli_status_to_errno(status);
                return -1;
        }