1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

r2634: use discard_const_p() in a few places

(This used to be commit 56ecda2178e33508c55c6195ccec41c06e099d6f)
This commit is contained in:
Andrew Tridgell 2004-09-25 12:48:56 +00:00 committed by Gerald (Jerry) Carter
parent 18104c5679
commit 6310f40448
5 changed files with 13 additions and 10 deletions

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;