svn commit: samba r17315 - in branches/SAMBA_3_0/source: lib tdb
vlendec at samba.org
vlendec at samba.org
Sun Jul 30 10:42:12 GMT 2006
Author: vlendec
Date: 2006-07-30 10:42:11 +0000 (Sun, 30 Jul 2006)
New Revision: 17315
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17315
Log:
Make talloc and tdb C++-warning-free. Would this also be interesting in talloc
and tdb "upstream"?
Volker
Modified:
branches/SAMBA_3_0/source/lib/talloc.c
branches/SAMBA_3_0/source/tdb/io.c
branches/SAMBA_3_0/source/tdb/open.c
branches/SAMBA_3_0/source/tdb/tdb.c
branches/SAMBA_3_0/source/tdb/tdbback.c
branches/SAMBA_3_0/source/tdb/tdbutil.c
branches/SAMBA_3_0/source/tdb/transaction.c
Changeset:
Modified: branches/SAMBA_3_0/source/lib/talloc.c
===================================================================
--- branches/SAMBA_3_0/source/lib/talloc.c 2006-07-29 19:14:24 UTC (rev 17314)
+++ branches/SAMBA_3_0/source/lib/talloc.c 2006-07-30 10:42:11 UTC (rev 17315)
@@ -111,7 +111,7 @@
/* panic if we get a bad magic value */
static struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr)
{
- const char *pp = ptr;
+ const char *pp = (const char *)ptr;
struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE);
if ((tc->flags & ~0xF) != TALLOC_MAGIC) {
TALLOC_ABORT("Bad talloc magic value - unknown value");
@@ -181,7 +181,7 @@
return NULL;
}
- tc = malloc(TC_HDR_SIZE+size);
+ tc = (struct talloc_chunk *)malloc(TC_HDR_SIZE+size);
if (tc == NULL) return NULL;
tc->size = size;
@@ -234,7 +234,8 @@
*/
static int talloc_reference_destructor(void *ptr)
{
- struct talloc_reference_handle *handle = ptr;
+ struct talloc_reference_handle *handle =
+ (struct talloc_reference_handle *)ptr;
struct talloc_chunk *tc1 = talloc_chunk_from_ptr(ptr);
struct talloc_chunk *tc2 = talloc_chunk_from_ptr(handle->ptr);
if (tc1->destructor != (talloc_destructor_t)-1) {
@@ -261,7 +262,8 @@
if (ptr == NULL) return NULL;
tc = talloc_chunk_from_ptr(ptr);
- handle = talloc_named_const(context, sizeof(*handle), TALLOC_MAGIC_REFERENCE);
+ handle = (struct talloc_reference_handle *)talloc_named_const(
+ context, sizeof(*handle), TALLOC_MAGIC_REFERENCE);
if (handle == NULL) return NULL;
@@ -543,7 +545,7 @@
if (tc->refs) {
int is_child;
struct talloc_reference_handle *handle = tc->refs;
- is_child = talloc_is_parent(handle, handle->ptr);
+ is_child = talloc_is_parent(handle, (const char *)handle->ptr);
talloc_reference_destructor(tc->refs);
if (is_child) {
return talloc_free(ptr);
@@ -639,13 +641,13 @@
return NULL;
}
- tc = new_ptr;
+ tc = (struct talloc_chunk *)new_ptr;
tc->flags &= ~TALLOC_FLAG_FREE;
if (tc->parent) {
- tc->parent->child = new_ptr;
+ tc->parent->child = (struct talloc_chunk *)new_ptr;
}
if (tc->child) {
- tc->child->parent = new_ptr;
+ tc->child->parent = (struct talloc_chunk *)new_ptr;
}
if (tc->prev) {
@@ -805,7 +807,8 @@
for (c=tc->child;c;c=c->next) {
if (c->name == TALLOC_MAGIC_REFERENCE) {
- struct talloc_reference_handle *handle = TC_PTR_FROM_CHUNK(c);
+ struct talloc_reference_handle *handle =
+ (struct talloc_reference_handle *)TC_PTR_FROM_CHUNK(c);
const char *name2 = talloc_get_name(handle->ptr);
fprintf(f, "%*sreference to: %s\n", depth*4, "", name2);
} else {
@@ -927,7 +930,8 @@
for (c=tc->child;c;c=c->next) {
if (c->name == TALLOC_MAGIC_REFERENCE) {
- struct talloc_reference_handle *handle = TC_PTR_FROM_CHUNK(c);
+ struct talloc_reference_handle *handle =
+ (struct talloc_reference_handle *)TC_PTR_FROM_CHUNK(c);
const char *name2 = talloc_get_name(handle->ptr);
sprintf_append(NULL, pps, plen, pbuflen,
@@ -1033,7 +1037,7 @@
if (!p) {
return NULL;
}
- ret = talloc_memdup(t, p, strlen(p) + 1);
+ ret = (char *)talloc_memdup(t, p, strlen(p) + 1);
if (ret) {
talloc_set_name_const(ret, ret);
}
@@ -1074,7 +1078,7 @@
for (len=0; len<n && p[len]; len++) ;
- ret = _talloc(t, len + 1);
+ ret = (char *)_talloc(t, len + 1);
if (!ret) { return NULL; }
memcpy(ret, p, len);
ret[len] = 0;
@@ -1106,7 +1110,7 @@
return NULL;
}
- ret = _talloc(t, len+1);
+ ret = (char *)_talloc(t, len+1);
if (ret) {
VA_COPY(ap2, ap);
vsnprintf(ret, len+1, fmt, ap2);
Modified: branches/SAMBA_3_0/source/tdb/io.c
===================================================================
--- branches/SAMBA_3_0/source/tdb/io.c 2006-07-29 19:14:24 UTC (rev 17314)
+++ branches/SAMBA_3_0/source/tdb/io.c 2006-07-30 10:42:11 UTC (rev 17315)
@@ -124,7 +124,7 @@
/* Endian conversion: we only ever deal with 4 byte quantities */
void *tdb_convert(void *buf, u32 size)
{
- u32 i, *p = buf;
+ u32 i, *p = (u32 *)buf;
for (i = 0; i < size / 4; i++)
p[i] = TDB_BYTEREV(p[i]);
return buf;
@@ -304,7 +304,8 @@
tdb->map_size += size;
if (tdb->flags & TDB_INTERNAL) {
- char *new_map_ptr = realloc(tdb->map_ptr, tdb->map_size);
+ char *new_map_ptr = (char *)realloc(tdb->map_ptr,
+ tdb->map_size);
if (!new_map_ptr) {
tdb->map_size -= size;
goto fail;
@@ -360,7 +361,7 @@
len = 1;
}
- if (!(buf = malloc(len))) {
+ if (!(buf = (char *)malloc(len))) {
/* Ensure ecode is set for log fn. */
tdb->ecode = TDB_ERR_OOM;
TDB_LOG((tdb, 0,"tdb_alloc_read malloc failed len=%d (%s)\n",
Modified: branches/SAMBA_3_0/source/tdb/open.c
===================================================================
--- branches/SAMBA_3_0/source/tdb/open.c 2006-07-29 19:14:24 UTC (rev 17314)
+++ branches/SAMBA_3_0/source/tdb/open.c 2006-07-30 10:42:11 UTC (rev 17315)
@@ -54,7 +54,7 @@
/* We make it up in memory, then write it out if not internal */
size = sizeof(struct tdb_header) + (hash_size+1)*sizeof(tdb_off_t);
- if (!(newdb = calloc(size, 1)))
+ if (!(newdb = (struct tdb_header *)calloc(size, 1)))
return TDB_ERRCODE(TDB_ERR_OOM, -1);
/* Fill in the header */
@@ -139,7 +139,7 @@
unsigned char *vp;
u32 vertest;
- if (!(tdb = calloc(1, sizeof *tdb))) {
+ if (!(tdb = (struct tdb_context *)calloc(1, sizeof *tdb))) {
/* Can't log this */
errno = ENOMEM;
goto fail;
@@ -257,7 +257,8 @@
tdb->map_size = st.st_size;
tdb->device = st.st_dev;
tdb->inode = st.st_ino;
- tdb->locked = calloc(tdb->header.hash_size+1, sizeof(tdb->locked[0]));
+ tdb->locked = (struct tdb_lock_type *)calloc(tdb->header.hash_size+1,
+ sizeof(tdb->locked[0]));
if (!tdb->locked) {
TDB_LOG((tdb, 2, "tdb_open_ex: "
"failed to allocate lock structure for %s\n",
Modified: branches/SAMBA_3_0/source/tdb/tdb.c
===================================================================
--- branches/SAMBA_3_0/source/tdb/tdb.c 2006-07-29 19:14:24 UTC (rev 17314)
+++ branches/SAMBA_3_0/source/tdb/tdb.c 2006-07-30 10:42:11 UTC (rev 17315)
@@ -355,9 +355,10 @@
dbuf = tdb_fetch(tdb, key);
if (dbuf.dptr == NULL) {
- dbuf.dptr = malloc(new_dbuf.dsize);
+ dbuf.dptr = (char *)malloc(new_dbuf.dsize);
} else {
- dbuf.dptr = realloc(dbuf.dptr, dbuf.dsize + new_dbuf.dsize);
+ dbuf.dptr = (char *)realloc(dbuf.dptr,
+ dbuf.dsize + new_dbuf.dsize);
}
if (dbuf.dptr == NULL) {
Modified: branches/SAMBA_3_0/source/tdb/tdbback.c
===================================================================
--- branches/SAMBA_3_0/source/tdb/tdbback.c 2006-07-29 19:14:24 UTC (rev 17314)
+++ branches/SAMBA_3_0/source/tdb/tdbback.c 2006-07-30 10:42:11 UTC (rev 17315)
@@ -63,7 +63,7 @@
{
char *ret;
int len = strlen(name) + strlen(suffix) + 1;
- ret = malloc(len);
+ ret = (char *)malloc(len);
if (!ret) {
fprintf(stderr,"Out of memory!\n");
exit(1);
Modified: branches/SAMBA_3_0/source/tdb/tdbutil.c
===================================================================
--- branches/SAMBA_3_0/source/tdb/tdbutil.c 2006-07-29 19:14:24 UTC (rev 17314)
+++ branches/SAMBA_3_0/source/tdb/tdbutil.c 2006-07-30 10:42:11 UTC (rev 17315)
@@ -209,7 +209,7 @@
int32 v_store;
SIVAL(&v_store,0,v);
- data.dptr = (void *)&v_store;
+ data.dptr = (char *)&v_store;
data.dsize = sizeof(int32);
return tdb_store(tdb, key, data, TDB_REPLACE);
@@ -269,7 +269,7 @@
BOOL ret = True;
SIVAL(&v_store, 0, value);
- data.dptr = (void *)&v_store;
+ data.dptr = (char *)&v_store;
data.dsize = sizeof(uint32);
if (tdb_store(tdb, key, data, TDB_REPLACE) == -1)
Modified: branches/SAMBA_3_0/source/tdb/transaction.c
===================================================================
--- branches/SAMBA_3_0/source/tdb/transaction.c 2006-07-29 19:14:24 UTC (rev 17314)
+++ branches/SAMBA_3_0/source/tdb/transaction.c 2006-07-30 10:42:11 UTC (rev 17315)
@@ -258,7 +258,8 @@
off > tdb->transaction->old_map_size)) {
unsigned char *data = best_el->data;
el = best_el;
- el->data = realloc(el->data, el->length + len);
+ el->data = (unsigned char *)realloc(el->data,
+ el->length + len);
if (el->data == NULL) {
tdb->ecode = TDB_ERR_OOM;
tdb->transaction->transaction_error = 1;
@@ -275,7 +276,7 @@
}
/* add a new entry at the end of the list */
- el = malloc(sizeof(*el));
+ el = (struct tdb_transaction_el *)malloc(sizeof(*el));
if (el == NULL) {
tdb->ecode = TDB_ERR_OOM;
tdb->transaction->transaction_error = 1;
@@ -285,7 +286,7 @@
el->prev = tdb->transaction->elements_last;
el->offset = off;
el->length = len;
- el->data = malloc(len);
+ el->data = (unsigned char *)malloc(len);
if (el->data == NULL) {
free(el);
tdb->ecode = TDB_ERR_OOM;
@@ -411,7 +412,8 @@
return -1;
}
- tdb->transaction = calloc(sizeof(struct tdb_transaction), 1);
+ tdb->transaction = (struct tdb_transaction *)
+ calloc(sizeof(struct tdb_transaction), 1);
if (tdb->transaction == NULL) {
tdb->ecode = TDB_ERR_OOM;
return -1;
@@ -437,7 +439,8 @@
/* setup a copy of the hash table heads so the hash scan in
traverse can be fast */
- tdb->transaction->hash_heads = calloc(tdb->header.hash_size+1, sizeof(tdb_off_t));
+ tdb->transaction->hash_heads = (unsigned int *)
+ calloc(tdb->header.hash_size+1, sizeof(tdb_off_t));
if (tdb->transaction->hash_heads == NULL) {
tdb->ecode = TDB_ERR_OOM;
goto fail;
@@ -678,7 +681,7 @@
return -1;
}
- data = malloc(recovery_size + sizeof(*rec));
+ data = (unsigned char *)malloc(recovery_size + sizeof(*rec));
if (data == NULL) {
tdb->ecode = TDB_ERR_OOM;
return -1;
@@ -960,7 +963,7 @@
recovery_eof = rec.key_len;
- data = malloc(rec.data_len);
+ data = (unsigned char *)malloc(rec.data_len);
if (data == NULL) {
TDB_LOG((tdb, 0, "tdb_transaction_recover: failed to allocate recovery data\n"));
tdb->ecode = TDB_ERR_OOM;
More information about the samba-cvs
mailing list