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;
}
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)
{
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;
}
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;
}
}
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;
}
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;