[PATCH] s3: Fix unrequired double condition check |Resend due to Jeremy's request

Swen Schillig swen at vnet.ibm.com
Mon Mar 19 09:44:25 UTC 2018


On Fri, 2018-03-09 at 08:55 +0100, Andreas Schneider via samba-
technical wrote:
> On Tuesday, 6 March 2018 11:44:55 CET Swen Schillig via samba-
> technical wrote:
> > Please review ... and push.
> > 
> > Thanks in advance.
> > 
> > Cheers Swen
> 
> 
> RB+ when changing DEBUG(10, ()) -> DBG_DEBUG()
> 
> 
Hi Jeremy, here's the first of the 3 remaining patches.

Please review and push if OK.

Thanks in advance.

Cheers Swen
-------------- next part --------------
From 9cf29525e91ad50d94f007b6d713152753d6bb1b 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 4480ec38882..8820a117457 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -1759,7 +1759,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) {
@@ -1782,28 +1782,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) {
+		DBG_DEBUG("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