[PATCH] s3: Fix unrequired double condition check
Swen Schillig
swen at vnet.ibm.com
Tue Mar 6 10:44:55 UTC 2018
Please review ... and push.
Thanks in advance.
Cheers Swen
-------------- next part --------------
From 67772e4051ed29dffff3c8c5c9629a83bf889ae2 Mon Sep 17 00:00:00 2001
From: Swen Schillig <swen at vnet.ibm.com>
Date: Mon, 5 Mar 2018 13:32:02 +0100
Subject: [PATCH] s3: Fix unrequired double condition check
Minor cleanup removing an repeated condition check and
replacing a goto by an early return.
Signed-off-by: Swen Schillig <swen at vnet.ibm.com>
---
source3/smbd/dir.c | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 95fe5777aad..1cd85e7f37d 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -1757,7 +1757,7 @@ static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx, connection_struct *conn,
struct smbd_server_connection *sconn = conn->sconn;
if (!dirp) {
- goto fail;
+ return NULL;
}
if (!fsp->is_directory) {
@@ -1780,28 +1780,24 @@ static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx, connection_struct *conn,
}
dirp->dir = SMB_VFS_FDOPENDIR(fsp, mask, attr);
- if (dirp->dir != NULL) {
- dirp->fsp = fsp;
- } else {
- DEBUG(10,("OpenDir_fsp: SMB_VFS_FDOPENDIR on %s returned "
- "NULL (%s)\n",
- dirp->dir_smb_fname->base_name,
- strerror(errno)));
+ if (dirp->dir == NULL) {
+ DEBUG(10, ("OpenDir_fsp: SMB_VFS_FDOPENDIR on %s returned "
+ "NULL (%s)\n", dirp->dir_smb_fname->base_name,
+ strerror(errno)));
+
+ TALLOC_FREE(dirp);
+
if (errno != ENOSYS) {
- goto fail;
+ return NULL;
}
- }
- if (dirp->dir == NULL) {
/* FDOPENDIR is not supported. Use OPENDIR instead. */
- TALLOC_FREE(dirp);
- return open_dir_safely(mem_ctx,
- conn,
- fsp->fsp_name,
- mask,
- attr);
+ return open_dir_safely(mem_ctx, conn, fsp->fsp_name, mask,
+ attr);
}
+ dirp->fsp = fsp;
+
if (sconn && !sconn->using_smb2) {
sconn->searches.dirhandles_open++;
}
--
2.14.3
More information about the samba-technical
mailing list