ITS#7720 don't do ptr arithmetic on void *s

This commit is contained in:
Howard Chu 2013-10-08 10:40:51 -07:00
parent 9689f20849
commit c82dcab9bd
2 changed files with 8 additions and 8 deletions

View File

@ -165,7 +165,7 @@ mdb_dn2id_add(
rc = mdb_cursor_get( mcp, &key, &data, MDB_SET ); rc = mdb_cursor_get( mcp, &key, &data, MDB_SET );
if ( !rc ) { if ( !rc ) {
char *p2; char *p2;
ptr = data.mv_data + data.mv_size - sizeof( ID ); ptr = (char *)data.mv_data + data.mv_size - sizeof( ID );
memcpy( &nid, ptr, sizeof( ID )); memcpy( &nid, ptr, sizeof( ID ));
/* Get parent's node under grandparent */ /* Get parent's node under grandparent */
d = data.mv_data; d = data.mv_data;
@ -178,7 +178,7 @@ mdb_dn2id_add(
op->o_tmpfree( p2, op->o_tmpmemctx ); op->o_tmpfree( p2, op->o_tmpmemctx );
if ( !rc ) { if ( !rc ) {
/* Get parent's subtree count */ /* Get parent's subtree count */
ptr = data.mv_data + data.mv_size - sizeof( ID ); ptr = (char *)data.mv_data + data.mv_size - sizeof( ID );
memcpy( &subs, ptr, sizeof( ID )); memcpy( &subs, ptr, sizeof( ID ));
subs += nsubs; subs += nsubs;
p2 = op->o_tmpalloc( data.mv_size, op->o_tmpmemctx ); p2 = op->o_tmpalloc( data.mv_size, op->o_tmpmemctx );
@ -246,7 +246,7 @@ mdb_dn2id_delete(
char *p2; char *p2;
diskNode *d; diskNode *d;
int rlen; int rlen;
ptr = data.mv_data + data.mv_size - sizeof( ID ); ptr = (char *)data.mv_data + data.mv_size - sizeof( ID );
memcpy( &nid, ptr, sizeof( ID )); memcpy( &nid, ptr, sizeof( ID ));
/* Get parent's node under grandparent */ /* Get parent's node under grandparent */
d = data.mv_data; d = data.mv_data;
@ -259,7 +259,7 @@ mdb_dn2id_delete(
op->o_tmpfree( p2, op->o_tmpmemctx ); op->o_tmpfree( p2, op->o_tmpmemctx );
if ( !rc ) { if ( !rc ) {
/* Get parent's subtree count */ /* Get parent's subtree count */
ptr = data.mv_data + data.mv_size - sizeof( ID ); ptr = (char *)data.mv_data + data.mv_size - sizeof( ID );
memcpy( &subs, ptr, sizeof( ID )); memcpy( &subs, ptr, sizeof( ID ));
subs -= nsubs; subs -= nsubs;
p2 = op->o_tmpalloc( data.mv_size, op->o_tmpmemctx ); p2 = op->o_tmpalloc( data.mv_size, op->o_tmpmemctx );
@ -399,7 +399,7 @@ mdb_dn2id(
*id = nid; *id = nid;
/* return subtree count if requested */ /* return subtree count if requested */
if ( !rc && nsubs ) { if ( !rc && nsubs ) {
ptr = data.mv_data + data.mv_size - sizeof(ID); ptr = (char *)data.mv_data + data.mv_size - sizeof(ID);
memcpy( nsubs, ptr, sizeof( ID )); memcpy( nsubs, ptr, sizeof( ID ));
} }
if ( !mc ) if ( !mc )
@ -795,7 +795,7 @@ mdb_dn2id_walk(
/* Get next sibling */ /* Get next sibling */
rc = mdb_cursor_get( isc->mc, &key, &data, MDB_NEXT_DUP ); rc = mdb_cursor_get( isc->mc, &key, &data, MDB_NEXT_DUP );
if ( !rc ) { if ( !rc ) {
ptr = data.mv_data + data.mv_size - 2*sizeof(ID); ptr = (char *)data.mv_data + data.mv_size - 2*sizeof(ID);
d = data.mv_data; d = data.mv_data;
memcpy( &isc->id, ptr, sizeof(ID)); memcpy( &isc->id, ptr, sizeof(ID));

View File

@ -1421,7 +1421,7 @@ mdb_dn2id_upgrade( BackendDB *be ) {
if (dkids > 1) { if (dkids > 1) {
rc = mdb_cursor_get(mc, &key, &data, MDB_NEXT_DUP); rc = mdb_cursor_get(mc, &key, &data, MDB_NEXT_DUP);
down: down:
ptr = data.mv_data + data.mv_size - sizeof(ID); ptr = (unsigned char *)data.mv_data + data.mv_size - sizeof(ID);
memcpy(&id, ptr, sizeof(ID)); memcpy(&id, ptr, sizeof(ID));
depth++; depth++;
memcpy(stack[depth].rdn, data.mv_data, data.mv_size); memcpy(stack[depth].rdn, data.mv_data, data.mv_size);
@ -1447,7 +1447,7 @@ pop:
goto leave; goto leave;
} }
data.mv_data = stack[depth].rdn; data.mv_data = stack[depth].rdn;
ptr = data.mv_data + data.mv_size; ptr = (unsigned char *)data.mv_data + data.mv_size;
memcpy(ptr, &num[depth], sizeof(ID)); memcpy(ptr, &num[depth], sizeof(ID));
data.mv_size += sizeof(ID); data.mv_size += sizeof(ID);
rc = mdb_cursor_del(mc, 0); rc = mdb_cursor_del(mc, 0);