summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-09-25 12:48:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:14 -0500
commit6310f40448f9f9e856874cbefcc25b753963a41e (patch)
treee4ce63697114f23b9cd93ad8d925e03e736ac7d9 /source4
parent18104c5679331c763f513f4c01b67b68f7a746fd (diff)
downloadsamba-6310f40448f9f9e856874cbefcc25b753963a41e.tar.gz
samba-6310f40448f9f9e856874cbefcc25b753963a41e.tar.bz2
samba-6310f40448f9f9e856874cbefcc25b753963a41e.zip
r2634: use discard_const_p() in a few places
(This used to be commit 56ecda2178e33508c55c6195ccec41c06e099d6f)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/tdb/common/tdbutil.c2
-rw-r--r--source4/lib/util.c7
-rw-r--r--source4/lib/util_unistr.c6
-rw-r--r--source4/librpc/rpc/dcerpc_util.c4
-rw-r--r--source4/ntvfs/ipc/vfs_ipc.c4
5 files changed, 13 insertions, 10 deletions
diff --git a/source4/lib/tdb/common/tdbutil.c b/source4/lib/tdb/common/tdbutil.c
index 596a79f52e..0e0a6eca28 100644
--- a/source4/lib/tdb/common/tdbutil.c
+++ b/source4/lib/tdb/common/tdbutil.c
@@ -82,7 +82,7 @@ static void (*TdbCatchSignal(int signum,void (*handler)(int )))(int)
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;
}
diff --git a/source4/lib/util.c b/source4/lib/util.c
index 910a35217c..2862a40bd7 100644
--- a/source4/lib/util.c
+++ b/source4/lib/util.c
@@ -944,8 +944,11 @@ BOOL all_zero(const char *ptr, uint_t size)
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)
{
diff --git a/source4/lib/util_unistr.c b/source4/lib/util_unistr.c
index 1d7d0de19a..2d4b2e8fa8 100644
--- a/source4/lib/util_unistr.c
+++ b/source4/lib/util_unistr.c
@@ -224,10 +224,10 @@ wide strchr()
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 @@ smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c)
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;
}
diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c
index 2a715eac1d..43cced0543 100644
--- a/source4/librpc/rpc/dcerpc_util.c
+++ b/source4/librpc/rpc/dcerpc_util.c
@@ -687,10 +687,10 @@ NTSTATUS dcerpc_secondary_connection(struct dcerpc_pipe *p, struct dcerpc_pipe *
}
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;
}
diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c
index 1ed2efba6b..ce6629739a 100644
--- a/source4/ntvfs/ipc/vfs_ipc.c
+++ b/source4/ntvfs/ipc/vfs_ipc.c
@@ -435,13 +435,13 @@ static NTSTATUS ipc_write(struct smbsrv_request *req, union smb_write *wr)
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;