svn commit: samba r2634 - in branches/SAMBA_4_0/source: lib lib/tdb/common librpc/rpc ntvfs/ipc

tridge at samba.org tridge at samba.org
Sat Sep 25 12:48:57 GMT 2004


Author: tridge
Date: 2004-09-25 12:48:56 +0000 (Sat, 25 Sep 2004)
New Revision: 2634

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source&rev=2634&nolog=1

Log:
use discard_const_p() in a few places



Modified:
   branches/SAMBA_4_0/source/lib/tdb/common/tdbutil.c
   branches/SAMBA_4_0/source/lib/util.c
   branches/SAMBA_4_0/source/lib/util_unistr.c
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
   branches/SAMBA_4_0/source/ntvfs/ipc/vfs_ipc.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/tdb/common/tdbutil.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/tdbutil.c	2004-09-25 12:48:09 UTC (rev 2633)
+++ branches/SAMBA_4_0/source/lib/tdb/common/tdbutil.c	2004-09-25 12:48:56 UTC (rev 2634)
@@ -82,7 +82,7 @@
 static TDB_DATA make_tdb_data(const char *dptr, size_t dsize)
 {
 	TDB_DATA ret;
-	ret.dptr = dptr;
+	ret.dptr = discard_const_p(char, dptr);
 	ret.dsize = dsize;
 	return ret;
 }

Modified: branches/SAMBA_4_0/source/lib/util.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util.c	2004-09-25 12:48:09 UTC (rev 2633)
+++ branches/SAMBA_4_0/source/lib/util.c	2004-09-25 12:48:56 UTC (rev 2634)
@@ -944,8 +944,11 @@
   we get new errors.
 
   Please only add more calls to this function when you find it
-  _really_ hard to fix const warnings. Our aim is to eventually not
-  need this function at all,
+  _really_ hard to fix const warnings. Our aim is to eventually use
+  this function in only a very few places.
+
+  Also, please call this via the discard_const_p() macro interface, as that
+  makes the return type safe.
 */
 void *discard_const(const void *ptr)
 {

Modified: branches/SAMBA_4_0/source/lib/util_unistr.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util_unistr.c	2004-09-25 12:48:09 UTC (rev 2633)
+++ branches/SAMBA_4_0/source/lib/util_unistr.c	2004-09-25 12:48:56 UTC (rev 2634)
@@ -224,10 +224,10 @@
 smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c)
 {
 	while (*s != 0) {
-		if (c == *s) return s;
+		if (c == *s) return discard_const_p(smb_ucs2_t, s);
 		s++;
 	}
-	if (c == *s) return s;
+	if (c == *s) return discard_const_p(smb_ucs2_t, s);
 
 	return NULL;
 }
@@ -244,7 +244,7 @@
 	if (len == 0) return NULL;
 	p += (len - 1);
 	do {
-		if (c == *p) return p;
+		if (c == *p) return discard_const_p(smb_ucs2_t, p);
 	} while (p-- != s);
 	return NULL;
 }

Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c	2004-09-25 12:48:09 UTC (rev 2633)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c	2004-09-25 12:48:56 UTC (rev 2634)
@@ -687,10 +687,10 @@
 }
 
 NTSTATUS dcerpc_generic_session_key(struct dcerpc_pipe *p,
-				  DATA_BLOB *session_key)
+				    DATA_BLOB *session_key)
 {
 	/* this took quite a few CPU cycles to find ... */
-	session_key->data = "SystemLibraryDTC";
+	session_key->data = discard_const_p(char, "SystemLibraryDTC");
 	session_key->length = 16;
 	return NT_STATUS_OK;
 }

Modified: branches/SAMBA_4_0/source/ntvfs/ipc/vfs_ipc.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/ipc/vfs_ipc.c	2004-09-25 12:48:09 UTC (rev 2633)
+++ branches/SAMBA_4_0/source/ntvfs/ipc/vfs_ipc.c	2004-09-25 12:48:56 UTC (rev 2634)
@@ -435,13 +435,13 @@
 	switch (wr->generic.level) {
 	case RAW_WRITE_WRITE:
 		fnum = wr->write.in.fnum;
-		data.data = wr->write.in.data;
+		data.data = discard_const_p(void, wr->write.in.data);
 		data.length = wr->write.in.count;
 		break;
 
 	case RAW_WRITE_WRITEX:
 		fnum = wr->writex.in.fnum;
-		data.data = wr->writex.in.data;
+		data.data = discard_const_p(void, wr->writex.in.data);
 		data.length = wr->writex.in.count;
 		break;
 



More information about the samba-cvs mailing list