The number of elements in an OSet cannot be negative.
Let the return type of VG_(OSetGen_Size) reflect that.
Also fix a few casts.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15491 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c
index dcc6220..f277f95 100644
--- a/cachegrind/cg_main.c
+++ b/cachegrind/cg_main.c
@@ -1698,11 +1698,11 @@
VG_(dmsg)("cachegrind: with zero info:%6.1f%% (%d)\n",
no_debugs * 100.0 / debug_lookups, no_debugs);
- VG_(dmsg)("cachegrind: string table size: %lu\n",
+ VG_(dmsg)("cachegrind: string table size: %u\n",
VG_(OSetGen_Size)(stringTable));
- VG_(dmsg)("cachegrind: CC table size: %lu\n",
+ VG_(dmsg)("cachegrind: CC table size: %u\n",
VG_(OSetGen_Size)(CC_table));
- VG_(dmsg)("cachegrind: InstrInfo table size: %lu\n",
+ VG_(dmsg)("cachegrind: InstrInfo table size: %u\n",
VG_(OSetGen_Size)(instrInfoTable));
}
}
diff --git a/coregrind/m_oset.c b/coregrind/m_oset.c
index d1b1729..358392e 100644
--- a/coregrind/m_oset.c
+++ b/coregrind/m_oset.c
@@ -117,7 +117,7 @@
OSetFree_t free_fn; // deallocator
PoolAlloc* node_pa; // (optional) pool allocator for nodes.
SizeT maxEltSize; // for node_pa, must be > 0. Otherwise unused.
- Word nElems; // number of elements in the tree
+ UInt nElems; // number of elements in the tree
AvlNode* root; // root node
AvlNode* nodeStack[STACK_MAX]; // Iterator node stack
@@ -912,7 +912,7 @@
/*--- Miscellaneous operations ---*/
/*--------------------------------------------------------------------*/
-Word VG_(OSetGen_Size)(const AvlTree* t)
+UInt VG_(OSetGen_Size)(const AvlTree* t)
{
vg_assert(t);
return t->nElems;
diff --git a/include/pub_tool_oset.h b/include/pub_tool_oset.h
index a52606c..a250c1f 100644
--- a/include/pub_tool_oset.h
+++ b/include/pub_tool_oset.h
@@ -298,7 +298,7 @@
// they will return NULL if VG_(OSetGen_Next)() is called without an
// intervening call to VG_(OSetGen_ResetIter)().
-extern Word VG_(OSetGen_Size) ( const OSet* os );
+extern UInt VG_(OSetGen_Size) ( const OSet* os );
extern void VG_(OSetGen_Insert) ( OSet* os, void* elem );
extern Bool VG_(OSetGen_Contains) ( const OSet* os, const void* key );
extern void* VG_(OSetGen_Lookup) ( const OSet* os, const void* key );
diff --git a/memcheck/mc_leakcheck.c b/memcheck/mc_leakcheck.c
index 42aeacb..84d4688 100644
--- a/memcheck/mc_leakcheck.c
+++ b/memcheck/mc_leakcheck.c
@@ -899,11 +899,10 @@
if (VG_DEBUG_CLIQUE) {
if (ex->IorC.indirect_szB > 0)
VG_(printf)(" clique %d joining clique %d adding %lu+%lu\n",
- ch_no, clique, (unsigned long)ch->szB,
- (unsigned long)ex->IorC.indirect_szB);
+ ch_no, clique, (SizeT)ch->szB, ex->IorC.indirect_szB);
else
VG_(printf)(" block %d joining clique %d adding %lu\n",
- ch_no, clique, (unsigned long)ch->szB);
+ ch_no, clique, (SizeT)ch->szB);
}
lc_extras[clique].IorC.indirect_szB += ch->szB;
@@ -1178,8 +1177,8 @@
// allocates or reallocates lr_array, and set its elements to the loss records
// contains in lr_table.
-static Int get_lr_array_from_lr_table(void) {
- Int i, n_lossrecords;
+static UInt get_lr_array_from_lr_table(void) {
+ UInt i, n_lossrecords;
LossRecord* lr;
n_lossrecords = VG_(OSetGen_Size)(lr_table);
@@ -1321,7 +1320,7 @@
if (VG_DEBUG_LEAKCHECK)
VG_(printf)("heuristic %s %#lx len %lu\n",
pp_heuristic(ex->heuristic),
- ch->data, (unsigned long)ch->szB);
+ ch->data, (SizeT)ch->szB);
}
old_lr = VG_(OSetGen_Lookup)(lr_table, &lrkey);
@@ -1511,7 +1510,7 @@
static void print_clique (Int clique, UInt level)
{
Int ind;
- Int i, n_lossrecords;;
+ UInt i, n_lossrecords;
n_lossrecords = VG_(OSetGen_Size)(lr_table);
@@ -1522,7 +1521,7 @@
MC_Chunk* ind_ch = lc_chunks[ind];
LossRecord* ind_lr;
LossRecordKey ind_lrkey;
- Int lr_i;
+ UInt lr_i;
ind_lrkey.state = ind_ex->state;
ind_lrkey.allocated_at = MC_(allocated_at)(ind_ch);
ind_lr = VG_(OSetGen_Lookup)(lr_table, &ind_lrkey);
@@ -1531,13 +1530,13 @@
break;
for (i = 0; i < level; i++)
VG_(umsg)(" ");
- VG_(umsg)("%p[%lu] indirect loss record %d\n",
- (void *)ind_ch->data, (unsigned long)ind_ch->szB,
+ VG_(umsg)("%p[%lu] indirect loss record %u\n",
+ (void *)ind_ch->data, (SizeT)ind_ch->szB,
lr_i+1); // lr_i+1 for user numbering.
if (lr_i >= n_lossrecords)
VG_(umsg)
("error: no indirect loss record found for %p[%lu]?????\n",
- (void *)ind_ch->data, (unsigned long)ind_ch->szB);
+ (void *)ind_ch->data, (SizeT)ind_ch->szB);
print_clique(ind, level+1);
}
}
@@ -1545,7 +1544,7 @@
Bool MC_(print_block_list) ( UInt loss_record_nr)
{
- Int i, n_lossrecords;
+ UInt i, n_lossrecords;
LossRecord* lr;
if (lr_table == NULL || lc_chunks == NULL || lc_extras == NULL) {
@@ -1584,7 +1583,7 @@
// If this is the loss record we are looking for, output the pointer.
if (old_lr == lr_array[loss_record_nr]) {
VG_(umsg)("%p[%lu]\n",
- (void *)ch->data, (unsigned long) ch->szB);
+ (void *)ch->data, (SizeT)ch->szB);
if (ex->state != Reachable) {
// We can print the clique in all states, except Reachable.
// In Unreached state, lc_chunk[i] is the clique leader.
@@ -1598,7 +1597,7 @@
} else {
// No existing loss record matches this chunk ???
VG_(umsg)("error: no loss record found for %p[%lu]?????\n",
- (void *)ch->data, (unsigned long) ch->szB);
+ (void *)ch->data, (SizeT)ch->szB);
}
}
return True;