[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Feb 24 19:51:03 MST 2012


The branch, master has been updated
       via  872fb6a Move dptr code over to TALLOC.
       via  e54cf15 Make dptr_path() and dptr_wcard() const.
      from  c9ef087 Fix const warnings.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 872fb6a3e0c6d95b7ff754d1a277d24d6a51ecaf
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Feb 24 17:16:08 2012 -0800

    Move dptr code over to TALLOC.
    
    Autobuild-User: Jeremy Allison <jra at samba.org>
    Autobuild-Date: Sat Feb 25 03:50:24 CET 2012 on sn-devel-104

commit e54cf1538752fcb38fd9ce84345520c4d0001474
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Feb 24 17:12:52 2012 -0800

    Make dptr_path() and dptr_wcard() const.

-----------------------------------------------------------------------

Summary of changes:
 source3/smbd/dir.c    |   31 +++++++++++--------------------
 source3/smbd/proto.h  |    4 ++--
 source3/smbd/trans2.c |    4 +---
 3 files changed, 14 insertions(+), 25 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index d8e26f6..d4faf42 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -215,7 +215,7 @@ static struct dptr_struct *dptr_get(struct smbd_server_connection *sconn,
  Get the dir path for a dir index.
 ****************************************************************************/
 
-char *dptr_path(struct smbd_server_connection *sconn, int key)
+const char *dptr_path(struct smbd_server_connection *sconn, int key)
 {
 	struct dptr_struct *dptr = dptr_get(sconn, key, false);
 	if (dptr)
@@ -227,7 +227,7 @@ char *dptr_path(struct smbd_server_connection *sconn, int key)
  Get the dir wcard for a dir index.
 ****************************************************************************/
 
-char *dptr_wcard(struct smbd_server_connection *sconn, int key)
+const char *dptr_wcard(struct smbd_server_connection *sconn, int key)
 {
 	struct dptr_struct *dptr = dptr_get(sconn, key, false);
 	if (dptr)
@@ -281,11 +281,7 @@ static void dptr_close_internal(struct dptr_struct *dptr)
 
 done:
 	TALLOC_FREE(dptr->dir_hnd);
-
-	/* Lanman 2 specific code */
-	SAFE_FREE(dptr->wcard);
-	SAFE_FREE(dptr->path);
-	SAFE_FREE(dptr);
+	TALLOC_FREE(dptr);
 }
 
 /****************************************************************************
@@ -494,18 +490,18 @@ NTSTATUS dptr_create(connection_struct *conn, files_struct *fsp,
 		dptr_idleoldest(sconn);
 	}
 
-	dptr = SMB_MALLOC_P(struct dptr_struct);
+	dptr = talloc(NULL, struct dptr_struct);
 	if(!dptr) {
-		DEBUG(0,("malloc fail in dptr_create.\n"));
+		DEBUG(0,("talloc fail in dptr_create.\n"));
 		TALLOC_FREE(dir_hnd);
 		return NT_STATUS_NO_MEMORY;
 	}
 
 	ZERO_STRUCTP(dptr);
 
-	dptr->path = SMB_STRDUP(path);
+	dptr->path = talloc_strdup(dptr, path);
 	if (!dptr->path) {
-		SAFE_FREE(dptr);
+		TALLOC_FREE(dptr);
 		TALLOC_FREE(dir_hnd);
 		return NT_STATUS_NO_MEMORY;
 	}
@@ -513,10 +509,9 @@ NTSTATUS dptr_create(connection_struct *conn, files_struct *fsp,
 	dptr->dir_hnd = dir_hnd;
 	dptr->spid = spid;
 	dptr->expect_close = expect_close;
-	dptr->wcard = SMB_STRDUP(wcard);
+	dptr->wcard = talloc_strdup(dptr, wcard);
 	if (!dptr->wcard) {
-		SAFE_FREE(dptr->path);
-		SAFE_FREE(dptr);
+		TALLOC_FREE(dptr);
 		TALLOC_FREE(dir_hnd);
 		return NT_STATUS_NO_MEMORY;
 	}
@@ -555,9 +550,7 @@ NTSTATUS dptr_create(connection_struct *conn, files_struct *fsp,
 			dptr->dnum = bitmap_find(sconn->searches.dptr_bmap, 0);
 			if(dptr->dnum == -1 || dptr->dnum > 254) {
 				DEBUG(0,("dptr_create: returned %d: Error - all old dirptrs in use ?\n", dptr->dnum));
-				SAFE_FREE(dptr->path);
-				SAFE_FREE(dptr->wcard);
-				SAFE_FREE(dptr);
+				TALLOC_FREE(dptr);
 				TALLOC_FREE(dir_hnd);
 				return NT_STATUS_TOO_MANY_OPENED_FILES;
 			}
@@ -587,9 +580,7 @@ NTSTATUS dptr_create(connection_struct *conn, files_struct *fsp,
 
 			if(dptr->dnum == -1 || dptr->dnum < 255) {
 				DEBUG(0,("dptr_create: returned %d: Error - all new dirptrs in use ?\n", dptr->dnum));
-				SAFE_FREE(dptr->path);
-				SAFE_FREE(dptr->wcard);
-				SAFE_FREE(dptr);
+				TALLOC_FREE(dptr);
 				TALLOC_FREE(dir_hnd);
 				return NT_STATUS_TOO_MANY_OPENED_FILES;
 			}
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 8124ee9..4ec91a1 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -189,8 +189,8 @@ bool make_dir_struct(TALLOC_CTX *ctx,
 			time_t date,
 			bool uc);
 bool init_dptrs(struct smbd_server_connection *sconn);
-char *dptr_path(struct smbd_server_connection *sconn, int key);
-char *dptr_wcard(struct smbd_server_connection *sconn, int key);
+const char *dptr_path(struct smbd_server_connection *sconn, int key);
+const char *dptr_wcard(struct smbd_server_connection *sconn, int key);
 uint16 dptr_attr(struct smbd_server_connection *sconn, int key);
 void dptr_close(struct smbd_server_connection *sconn, int *key);
 void dptr_closecnum(connection_struct *conn);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index d2eff4d..5ee02c4 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -2773,14 +2773,12 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
 	directory = dptr_path(sconn, dptr_num);
 
 	/* Get the wildcard mask from the dptr */
-	if((p = dptr_wcard(sconn, dptr_num))== NULL) {
+	if((mask = dptr_wcard(sconn, dptr_num))== NULL) {
 		DEBUG(2,("dptr_num %d has no wildcard\n", dptr_num));
 		reply_nterror(req, STATUS_NO_MORE_FILES);
 		return;
 	}
 
-	mask = p;
-
 	/* Get the attr mask from the dptr */
 	dirtype = dptr_attr(sconn, dptr_num);
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list