Fixed a bunch of gcc type punned pointer warnings.

This commit is contained in:
Sears Russell 2006-07-25 21:14:33 +00:00
parent 41528ef066
commit 89b45da869
5 changed files with 50 additions and 32 deletions

View file

@ -134,9 +134,11 @@ START_TEST(iteratorTest)
i = 0;
while(Titerator_next(-1, arrayIt)) {
unsigned int * key;
unsigned int ** bkey = &key;
unsigned char * value;
int keySize = Titerator_key(-1, arrayIt, (byte**)&key);
int valueSize = Titerator_value(-1, arrayIt, (byte**)&value);
unsigned char ** bvalue = &value;
int keySize = Titerator_key(-1, arrayIt, (byte**)bkey);
int valueSize = Titerator_value(-1, arrayIt, (byte**)bvalue);
assert(keySize == sizeof(unsigned int));
assert(valueSize == sizeof(unsigned char));
assert(*key == i);

View file

@ -66,6 +66,7 @@ START_TEST(linearHashNTAtest)
recordid val;
recordid hashHeader = ThashCreate(xid, sizeof(int), sizeof(recordid));
recordid * val2;
recordid ** bval2 = &val2;
int i;
printf("\n"); fflush(stdout);
for(i = 0; i < NUM_ENTRIES; i++) {
@ -75,10 +76,10 @@ START_TEST(linearHashNTAtest)
val.page = i * NUM_ENTRIES;
val.slot = val.page * NUM_ENTRIES;
val.size = val.slot * NUM_ENTRIES;
int found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)&val2);
int found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)bval2);
assert(-1 == found);
ThashInsert(xid, hashHeader, (byte*)&i, sizeof(int), (byte*)&val, sizeof(recordid));
found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)&val2);
found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)bval2);
assert(sizeof(recordid) == found);
assert(val2->page == i * NUM_ENTRIES);
assert(val2->slot == val2->page * NUM_ENTRIES);
@ -94,12 +95,12 @@ START_TEST(linearHashNTAtest)
if(!(i % (NUM_ENTRIES/10))) {
printf("-"); fflush(stdout);
}
int found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)&val2);
int found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)bval2);
assert(sizeof(recordid) == found);
free(val2);
found = ThashRemove(xid, hashHeader, (byte*)&i, sizeof(int));
assert(found);
found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)&val2);
found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)bval2);
assert(-1==found);
found = ThashRemove(xid, hashHeader, (byte*)&i, sizeof(int));
assert(!found);
@ -111,7 +112,7 @@ START_TEST(linearHashNTAtest)
if(!(i % (NUM_ENTRIES/10))) {
printf("+"); fflush(stdout);
}
int found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)&val2);
int found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)bval2);
assert(sizeof(recordid) == found);
assert(val2->page == i * NUM_ENTRIES);
assert(val2->slot == val2->page * NUM_ENTRIES);
@ -132,6 +133,7 @@ START_TEST(linearHashNTAVariableSizetest)
recordid val;
recordid hashHeader = ThashCreate(xid, VARIABLE_LENGTH, VARIABLE_LENGTH);
recordid * val2;
recordid ** bval2 = &val2;
int i;
for(i = 0; i < NUM_ENTRIES; i++) {
if(!(i % (NUM_ENTRIES/10))) {
@ -141,11 +143,11 @@ START_TEST(linearHashNTAVariableSizetest)
val.slot = val.page * NUM_ENTRIES;
val.size = val.slot * NUM_ENTRIES;
val2 = 0;
int found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)&val2);
int found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)bval2);
assert(-1 == found);
ThashInsert(xid, hashHeader, (byte*)&i, sizeof(int), (byte*)&val, sizeof(recordid));
val2 =0;
int ret = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)&val2);
int ret = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)bval2);
assert(sizeof(recordid) == ret);
assert(val2->page == i * NUM_ENTRIES);
@ -161,12 +163,12 @@ START_TEST(linearHashNTAVariableSizetest)
if(!(i % (NUM_ENTRIES/10))) {
printf("-"); fflush(stdout);
}
int found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)&val2);
int found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)bval2);
assert(sizeof(recordid) == found);
free(val2);
found = ThashRemove(xid, hashHeader, (byte*)&i, sizeof(int));
assert(found);
found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)&val2);
found = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)bval2);
assert(-1==found);
found = ThashRemove(xid, hashHeader, (byte*)&i, sizeof(int));
assert(!found);
@ -178,7 +180,7 @@ START_TEST(linearHashNTAVariableSizetest)
if(!(i % (NUM_ENTRIES/10))) {
printf("+"); fflush(stdout);
}
int ret = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)&val2);
int ret = ThashLookup(xid, hashHeader, (byte*)&i, sizeof(int), (byte**)bval2);
assert(sizeof(recordid) == ret);
assert(val2->page == i * NUM_ENTRIES);
assert(val2->slot == val2->page * NUM_ENTRIES);
@ -228,12 +230,13 @@ void * worker(void* arg) {
Tcommit(xid);
xid = Tbegin();
int * value;
int ** bvalue = &value;
for(i = 0; i < NUM_T_ENTRIES; i+=10) {
int * value;
recordid key = makekey(thread,i);
int found = ThashRemove(xid, hash, (byte*)&key, sizeof(recordid));
assert(found);
found = ThashLookup(xid, hash, (byte*)&key, sizeof(recordid), (byte**)&value);
found = ThashLookup(xid, hash, (byte*)&key, sizeof(recordid), (byte**)bvalue);
assert(-1==found);
found = ThashRemove(xid, hash, (byte*)&key, sizeof(recordid));
assert(!found);
@ -244,8 +247,7 @@ void * worker(void* arg) {
for(i = 0; i < NUM_T_ENTRIES; i+=10) {
recordid key = makekey(thread,i);
int * value;
int found = ThashLookup(xid, hash, (byte*)&key, sizeof(recordid), (byte**)&value);
int found = ThashLookup(xid, hash, (byte*)&key, sizeof(recordid), (byte**)bvalue);
assert(sizeof(int) == found);
assert(*value == i + thread * NUM_T_ENTRIES);
free (value);
@ -328,11 +330,13 @@ START_TEST(linearHashNTAIteratortest) {
lladd_hash_iterator * it = ThashIterator(xid, hash, sizeof(int), sizeof(recordid));
int * key;
int ** bkey = &key;
recordid * value;
recordid ** bvalue = &value;
int keySize;
int valueSize;
while(ThashNext(xid, it, (byte**)&key, &keySize, (byte**)&value, &valueSize)) {
while(ThashNext(xid, it, (byte**)bkey, &keySize, (byte**)bvalue, &valueSize)) {
recordid check = makekey(0, *key);
assert(!memcmp(value, &check, sizeof(recordid)));

View file

@ -67,10 +67,11 @@ START_TEST(linkedListNTAtest)
val.page = i * 1000;
val.slot = val.page * 1000;
val.size = val.slot * 1000;
int found = TlinkedListFind(xid, linkedList, (byte*)(&i), sizeof(int), (byte**)&val2);
recordid ** bval2 = &val2;
int found = TlinkedListFind(xid, linkedList, (byte*)(&i), sizeof(int), (byte**)bval2);
assert(-1==found);
TlinkedListInsert(xid, linkedList, (byte*)&i, sizeof(int), (byte*)&val, sizeof(recordid));
found = TlinkedListFind(xid, linkedList, (byte*)(&i), sizeof(int), (byte**)&val2);
found = TlinkedListFind(xid, linkedList, (byte*)(&i), sizeof(int), (byte**)bval2);
assert(sizeof(recordid)==found);
assert(!memcmp(&val, val2, sizeof(recordid)));
free(val2);
@ -81,7 +82,8 @@ START_TEST(linkedListNTAtest)
xid = Tbegin();
for(i = 0; i < 1000; i+=10) {
recordid * val2 = NULL;
int found = TlinkedListFind(xid, linkedList, (byte*)(&i), sizeof(int), (byte**)&val2);
recordid ** bval2 = &val2;
int found = TlinkedListFind(xid, linkedList, (byte*)(&i), sizeof(int), (byte**)bval2);
assert(sizeof(recordid)==found);
assert(val2->page == i * 1000);
assert(val2->slot == i * 1000 * 1000);
@ -90,7 +92,7 @@ START_TEST(linkedListNTAtest)
found = TlinkedListRemove(xid, linkedList, (byte*)&i, sizeof(int));
assert(found);
found = TlinkedListFind(xid, linkedList, (byte*)(&i), sizeof(int), (byte**)&val2);
found = TlinkedListFind(xid, linkedList, (byte*)(&i), sizeof(int), (byte**)bval2);
assert(-1==found);
found = TlinkedListRemove(xid, linkedList, (byte*)&i, sizeof(int));
assert(!found);
@ -99,7 +101,8 @@ START_TEST(linkedListNTAtest)
xid = Tbegin();
for(i = 0; i < 1000; i++) {
recordid * val2;
int found = TlinkedListFind(xid, linkedList, (byte*)(&i), sizeof(int), (byte**)&val2);
recordid ** bval2 = &val2;
int found = TlinkedListFind(xid, linkedList, (byte*)(&i), sizeof(int), (byte**)bval2);
assert(sizeof(recordid)==found);
assert(val2->page == i * 1000);
assert(val2->slot == i * 1000 * 1000);
@ -149,7 +152,8 @@ static void * worker(void * arg) {
for(i = 0; i < NUM_T_ENTRIES; i++) {
recordid key = makekey(thread, i);
int * value;
int ret = TlinkedListFind(xid, listRoot, (byte*)&key, sizeof(recordid), (byte**)&value);
int ** bvalue = &value;
int ret = TlinkedListFind(xid, listRoot, (byte*)&key, sizeof(recordid), (byte**)bvalue);
assert(ret == sizeof(int));
assert(*value == i+thread*NUM_THREADS);
free(value);

View file

@ -145,8 +145,9 @@ static void * go2( void * arg) {
while((itRet = Titerator_next(-1, it))) {
lladdFifo_t ** dirtyFifo_ptr;
lladdFifo_t *** bdirtyFifo_ptr = &dirtyFifo_ptr;
lladdFifo_t * dirtyFifo;
int dirtyFifoSize = Titerator_value(-1, it, (byte**)&dirtyFifo_ptr);
int dirtyFifoSize = Titerator_value(-1, it, (byte**)bdirtyFifo_ptr);
dirtyFifo = * dirtyFifo_ptr;

View file

@ -60,9 +60,11 @@ START_TEST(emptyIterator) {
int keySize;
int valueSize;
int * key = 0;
int ** bkey = &key;
recordid * value = 0;
while(TpagedListNext(xid, it, (byte**)&key, &keySize, (byte**)&value, &valueSize)) {
recordid ** bvalue = &value;
while(TpagedListNext(xid, it, (byte**)bkey, &keySize, (byte**)bvalue, &valueSize)) {
abort();
}
Tcommit(xid);
@ -97,7 +99,8 @@ START_TEST(pagedListCheck) {
assert(!ret);
recordid * bb;
ret = TpagedListFind(xid, list, (byte*)&a, sizeof(int), (byte**)&bb);
recordid ** bbb = &bb;
ret = TpagedListFind(xid, list, (byte*)&a, sizeof(int), (byte**)bbb);
assert(ret == sizeof(recordid));
assert(!memcmp(bb, &b, sizeof(recordid)));
@ -117,7 +120,8 @@ START_TEST(pagedListCheck) {
b.size = i+3;
recordid * bb;
int ret = TpagedListFind(xid, list, (byte*)&a, sizeof(int), (byte**)&bb);
recordid ** bbb = &bb;
int ret = TpagedListFind(xid, list, (byte*)&a, sizeof(int), (byte**)bbb);
assert(ret == sizeof(recordid));
assert(!memcmp(bb, &b, sizeof(recordid)));
@ -131,8 +135,8 @@ START_TEST(pagedListCheck) {
free(bb);
bb = 0;
ret = TpagedListFind(xid, list, (byte*)&a, sizeof(int), (byte**)&bb);
ret = TpagedListFind(xid, list, (byte*)&a, sizeof(int), (byte**)bbb);
assert(-1==ret);
assert(!bb);
@ -154,7 +158,8 @@ START_TEST(pagedListCheck) {
b.size = i+3;
recordid * bb;
int ret = TpagedListFind(xid, list, (byte*)&a, sizeof(int), (byte**)&bb);
recordid ** bbb = &bb;
int ret = TpagedListFind(xid, list, (byte*)&a, sizeof(int), (byte**)bbb);
assert(ret == sizeof(recordid));
assert(!memcmp(bb, &b, sizeof(recordid)));
@ -167,9 +172,11 @@ START_TEST(pagedListCheck) {
int keySize;
int valueSize;
int * key = 0;
int ** bkey = &key;
recordid * value = 0;
recordid ** bvalue = &value;
while(TpagedListNext(xid, it, (byte**)&key, &keySize, (byte**)&value, &valueSize)) {
while(TpagedListNext(xid, it, (byte**)bkey, &keySize, (byte**)bvalue, &valueSize)) {
assert(!seen[*key]);
seen[*key] = 1;