svn commit: samba r22688 - in branches: SAMBA_3_0/source/include SAMBA_3_0/source/locking SAMBA_3_0_26/source/include SAMBA_3_0_26/source/locking

vlendec at samba.org vlendec at samba.org
Sat May 5 20:43:07 GMT 2007


Author: vlendec
Date: 2007-05-05 20:43:06 +0000 (Sat, 05 May 2007)
New Revision: 22688

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22688

Log:
Change lock_data in struct byte_range_lock from void * to struct lock_struct *

Modified:
   branches/SAMBA_3_0/source/include/locking.h
   branches/SAMBA_3_0/source/locking/brlock.c
   branches/SAMBA_3_0_26/source/include/locking.h
   branches/SAMBA_3_0_26/source/locking/brlock.c


Changeset:
Modified: branches/SAMBA_3_0/source/include/locking.h
===================================================================
--- branches/SAMBA_3_0/source/include/locking.h	2007-05-05 20:41:21 UTC (rev 22687)
+++ branches/SAMBA_3_0/source/include/locking.h	2007-05-05 20:43:06 UTC (rev 22688)
@@ -57,7 +57,7 @@
 	BOOL modified;
 	BOOL read_only;
 	struct lock_key key;
-	void *lock_data;
+	struct lock_struct *lock_data;
 };
 
 #define BRLOCK_FN_CAST() \

Modified: branches/SAMBA_3_0/source/locking/brlock.c
===================================================================
--- branches/SAMBA_3_0/source/locking/brlock.c	2007-05-05 20:41:21 UTC (rev 22687)
+++ branches/SAMBA_3_0/source/locking/brlock.c	2007-05-05 20:43:06 UTC (rev 22688)
@@ -317,7 +317,7 @@
 {
 	unsigned int i;
 	files_struct *fsp = br_lck->fsp;
-	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	struct lock_struct *locks = br_lck->lock_data;
 
 	for (i=0; i < br_lck->num_locks; i++) {
 		/* Do any Windows or POSIX locks conflict ? */
@@ -362,7 +362,7 @@
 
 	memcpy(&locks[br_lck->num_locks], plock, sizeof(struct lock_struct));
 	br_lck->num_locks += 1;
-	br_lck->lock_data = (void *)locks;
+	br_lck->lock_data = locks;
 	br_lck->modified = True;
 
 	return NT_STATUS_OK;
@@ -588,7 +588,7 @@
 			const struct lock_struct *plock)
 {
 	unsigned int i, count;
-	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	struct lock_struct *locks = br_lck->lock_data;
 	struct lock_struct *tp;
 	BOOL lock_was_added = False;
 	BOOL signal_pending_read = False;
@@ -686,7 +686,7 @@
 	}
 	br_lck->num_locks = count;
 	SAFE_FREE(br_lck->lock_data);
-	br_lck->lock_data = (void *)tp;
+	br_lck->lock_data = tp;
 	locks = tp;
 	br_lck->modified = True;
 
@@ -770,7 +770,7 @@
 static BOOL brl_unlock_windows(struct byte_range_lock *br_lck, const struct lock_struct *plock)
 {
 	unsigned int i, j;
-	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	struct lock_struct *locks = br_lck->lock_data;
 	enum brl_type deleted_lock_type = READ_LOCK; /* shut the compiler up.... */
 
 #if ZERO_ZERO
@@ -873,7 +873,7 @@
 {
 	unsigned int i, j, count;
 	struct lock_struct *tp;
-	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	struct lock_struct *locks = br_lck->lock_data;
 	BOOL overlap_found = False;
 
 	/* No zero-zero locks for POSIX. */
@@ -1006,7 +1006,7 @@
 	br_lck->num_locks = count;
 	SAFE_FREE(br_lck->lock_data);
 	locks = tp;
-	br_lck->lock_data = (void *)tp;
+	br_lck->lock_data = tp;
 	br_lck->modified = True;
 
 	/* Send unlock messages to any pending waiters that overlap. */
@@ -1078,7 +1078,7 @@
 	BOOL ret = True;
 	unsigned int i;
 	struct lock_struct lock;
-	const struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	const struct lock_struct *locks = br_lck->lock_data;
 	files_struct *fsp = br_lck->fsp;
 
 	lock.context.smbpid = smbpid;
@@ -1135,7 +1135,7 @@
 {
 	unsigned int i;
 	struct lock_struct lock;
-	const struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	const struct lock_struct *locks = br_lck->lock_data;
 	files_struct *fsp = br_lck->fsp;
 
 	lock.context.smbpid = *psmbpid;
@@ -1201,7 +1201,7 @@
 		enum brl_flavour lock_flav)
 {
 	unsigned int i;
-	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	struct lock_struct *locks = br_lck->lock_data;
 	struct lock_context context;
 
 	context.smbpid = smbpid;
@@ -1251,7 +1251,7 @@
 	int fnum = fsp->fnum;
 	unsigned int i, j, dcount=0;
 	int num_deleted_windows_locks = 0;
-	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	struct lock_struct *locks = br_lck->lock_data;
 	struct process_id pid = procid_self();
 	BOOL unlock_individually = False;
 
@@ -1586,7 +1586,7 @@
 	talloc_set_destructor(br_lck, byte_range_lock_destructor);
 
 	data = tdb_fetch(tdb, key);
-	br_lck->lock_data = (void *)data.dptr;
+	br_lck->lock_data = (struct lock_struct *)data.dptr;
 	br_lck->num_locks = data.dsize / sizeof(struct lock_struct);
 
 	if (!fsp->lockdb_clean) {
@@ -1595,29 +1595,20 @@
 		/* Go through and ensure all entries exist - remove any that don't. */
 		/* Makes the lockdb self cleaning at low cost. */
 
-		struct lock_struct *locks =
-			(struct lock_struct *)br_lck->lock_data;
-
-		if (!validate_lock_entries(&br_lck->num_locks, &locks)) {
+		if (!validate_lock_entries(&br_lck->num_locks,
+					   &br_lck->lock_data)) {
 			SAFE_FREE(br_lck->lock_data);
 			TALLOC_FREE(br_lck);
 			return NULL;
 		}
 
-		/*
-		 * validate_lock_entries might have changed locks. We can't
-		 * use a direct pointer here because otherwise gcc warnes
-		 * about strict aliasing rules being violated.
-		 */
-		br_lck->lock_data = locks;
-
 		/* Mark the lockdb as "clean" as seen from this open file. */
 		fsp->lockdb_clean = True;
 	}
 
 	if (DEBUGLEVEL >= 10) {
 		unsigned int i;
-		struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+		struct lock_struct *locks = br_lck->lock_data;
 		DEBUG(10,("brl_get_locks_internal: %u current locks on dev=%.0f, inode=%.0f\n",
 			br_lck->num_locks,
 			(double)fsp->dev, (double)fsp->inode ));

Modified: branches/SAMBA_3_0_26/source/include/locking.h
===================================================================
--- branches/SAMBA_3_0_26/source/include/locking.h	2007-05-05 20:41:21 UTC (rev 22687)
+++ branches/SAMBA_3_0_26/source/include/locking.h	2007-05-05 20:43:06 UTC (rev 22688)
@@ -57,7 +57,7 @@
 	BOOL modified;
 	BOOL read_only;
 	struct lock_key key;
-	void *lock_data;
+	struct lock_struct *lock_data;
 };
 
 #define BRLOCK_FN_CAST() \

Modified: branches/SAMBA_3_0_26/source/locking/brlock.c
===================================================================
--- branches/SAMBA_3_0_26/source/locking/brlock.c	2007-05-05 20:41:21 UTC (rev 22687)
+++ branches/SAMBA_3_0_26/source/locking/brlock.c	2007-05-05 20:43:06 UTC (rev 22688)
@@ -317,7 +317,7 @@
 {
 	unsigned int i;
 	files_struct *fsp = br_lck->fsp;
-	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	struct lock_struct *locks = br_lck->lock_data;
 
 	for (i=0; i < br_lck->num_locks; i++) {
 		/* Do any Windows or POSIX locks conflict ? */
@@ -362,7 +362,7 @@
 
 	memcpy(&locks[br_lck->num_locks], plock, sizeof(struct lock_struct));
 	br_lck->num_locks += 1;
-	br_lck->lock_data = (void *)locks;
+	br_lck->lock_data = locks;
 	br_lck->modified = True;
 
 	return NT_STATUS_OK;
@@ -588,7 +588,7 @@
 			const struct lock_struct *plock)
 {
 	unsigned int i, count;
-	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	struct lock_struct *locks = br_lck->lock_data;
 	struct lock_struct *tp;
 	BOOL lock_was_added = False;
 	BOOL signal_pending_read = False;
@@ -686,7 +686,7 @@
 	}
 	br_lck->num_locks = count;
 	SAFE_FREE(br_lck->lock_data);
-	br_lck->lock_data = (void *)tp;
+	br_lck->lock_data = tp;
 	locks = tp;
 	br_lck->modified = True;
 
@@ -770,7 +770,7 @@
 static BOOL brl_unlock_windows(struct byte_range_lock *br_lck, const struct lock_struct *plock)
 {
 	unsigned int i, j;
-	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	struct lock_struct *locks = br_lck->lock_data;
 	enum brl_type deleted_lock_type = READ_LOCK; /* shut the compiler up.... */
 
 #if ZERO_ZERO
@@ -873,7 +873,7 @@
 {
 	unsigned int i, j, count;
 	struct lock_struct *tp;
-	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	struct lock_struct *locks = br_lck->lock_data;
 	BOOL overlap_found = False;
 
 	/* No zero-zero locks for POSIX. */
@@ -1006,7 +1006,7 @@
 	br_lck->num_locks = count;
 	SAFE_FREE(br_lck->lock_data);
 	locks = tp;
-	br_lck->lock_data = (void *)tp;
+	br_lck->lock_data = tp;
 	br_lck->modified = True;
 
 	/* Send unlock messages to any pending waiters that overlap. */
@@ -1078,7 +1078,7 @@
 	BOOL ret = True;
 	unsigned int i;
 	struct lock_struct lock;
-	const struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	const struct lock_struct *locks = br_lck->lock_data;
 	files_struct *fsp = br_lck->fsp;
 
 	lock.context.smbpid = smbpid;
@@ -1135,7 +1135,7 @@
 {
 	unsigned int i;
 	struct lock_struct lock;
-	const struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	const struct lock_struct *locks = br_lck->lock_data;
 	files_struct *fsp = br_lck->fsp;
 
 	lock.context.smbpid = *psmbpid;
@@ -1201,7 +1201,7 @@
 		enum brl_flavour lock_flav)
 {
 	unsigned int i;
-	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	struct lock_struct *locks = br_lck->lock_data;
 	struct lock_context context;
 
 	context.smbpid = smbpid;
@@ -1251,7 +1251,7 @@
 	int fnum = fsp->fnum;
 	unsigned int i, j, dcount=0;
 	int num_deleted_windows_locks = 0;
-	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+	struct lock_struct *locks = br_lck->lock_data;
 	struct process_id pid = procid_self();
 	BOOL unlock_individually = False;
 
@@ -1586,7 +1586,7 @@
 	talloc_set_destructor(br_lck, byte_range_lock_destructor);
 
 	data = tdb_fetch(tdb, key);
-	br_lck->lock_data = (void *)data.dptr;
+	br_lck->lock_data = (struct lock_struct *)data.dptr;
 	br_lck->num_locks = data.dsize / sizeof(struct lock_struct);
 
 	if (!fsp->lockdb_clean) {
@@ -1595,29 +1595,20 @@
 		/* Go through and ensure all entries exist - remove any that don't. */
 		/* Makes the lockdb self cleaning at low cost. */
 
-		struct lock_struct *locks =
-			(struct lock_struct *)br_lck->lock_data;
-
-		if (!validate_lock_entries(&br_lck->num_locks, &locks)) {
+		if (!validate_lock_entries(&br_lck->num_locks,
+					   &br_lck->lock_data)) {
 			SAFE_FREE(br_lck->lock_data);
 			TALLOC_FREE(br_lck);
 			return NULL;
 		}
 
-		/*
-		 * validate_lock_entries might have changed locks. We can't
-		 * use a direct pointer here because otherwise gcc warnes
-		 * about strict aliasing rules being violated.
-		 */
-		br_lck->lock_data = locks;
-
 		/* Mark the lockdb as "clean" as seen from this open file. */
 		fsp->lockdb_clean = True;
 	}
 
 	if (DEBUGLEVEL >= 10) {
 		unsigned int i;
-		struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
+		struct lock_struct *locks = br_lck->lock_data;
 		DEBUG(10,("brl_get_locks_internal: %u current locks on dev=%.0f, inode=%.0f\n",
 			br_lck->num_locks,
 			(double)fsp->dev, (double)fsp->inode ));



More information about the samba-cvs mailing list