From 2f11fd7b65686d789f02ffc3f49c3dab0ff511ab Mon Sep 17 00:00:00 2001
From: David Lovemore
Date: Tue, 31 Jul 2012 14:19:26 +0100
Subject: [PATCH] Tidy up code from unused variable warnings.
Copied from Perforce
Change: 178787
ServerID: perforce.ravenbrook.com
---
mps/code/abq.c | 3 +--
mps/code/awlut.c | 4 +---
mps/code/awluthe.c | 4 +---
mps/code/finaltest.c | 4 ----
mps/code/fmtdy.c | 30 ++++++++++++++++++++++--------
mps/code/locus.c | 3 ++-
mps/code/poolamc.c | 2 --
mps/code/poollo.c | 7 -------
mps/code/poolmrg.c | 3 ---
mps/code/poolmv.c | 2 --
mps/code/reserv.c | 2 --
mps/code/seg.c | 2 +-
mps/code/segsmss.c | 8 --------
13 files changed, 28 insertions(+), 46 deletions(-)
diff --git a/mps/code/abq.c b/mps/code/abq.c
index 05792e4add4..e29a9786599 100644
--- a/mps/code/abq.c
+++ b/mps/code/abq.c
@@ -168,7 +168,7 @@ Res ABQPeek(ABQ abq, CBSBlock *blockReturn)
/* ABQDelete -- delete a block from the ABQ */
Res ABQDelete(ABQ abq, CBSBlock block)
{
- Index index, next, elements, in;
+ Index index, next, in;
CBSBlock *queue;
AVERT(ABQ, abq);
@@ -178,7 +178,6 @@ Res ABQDelete(ABQ abq, CBSBlock block)
index = abq->out;
in = abq->in;
- elements = abq->elements;
queue = abq->queue;
while (index != in) {
diff --git a/mps/code/awlut.c b/mps/code/awlut.c
index d52abae9030..965fb4642a0 100644
--- a/mps/code/awlut.c
+++ b/mps/code/awlut.c
@@ -206,9 +206,7 @@ static void test(mps_ap_t leafap, mps_ap_t exactap, mps_ap_t weakap,
for(j = 0; j < ITERATIONS; ++j) {
for(i = 0; i < TABLE_SLOTS; ++i) {
- mps_word_t *string;
-
- string = alloc_string("spong", leafap);
+ (void)alloc_string("spong", leafap);
}
}
diff --git a/mps/code/awluthe.c b/mps/code/awluthe.c
index d70d12cb342..4b8d96df371 100644
--- a/mps/code/awluthe.c
+++ b/mps/code/awluthe.c
@@ -211,9 +211,7 @@ static void test(mps_ap_t leafap, mps_ap_t exactap, mps_ap_t weakap,
for(j = 0; j < ITERATIONS; ++j) {
for(i = 0; i < TABLE_SLOTS; ++i) {
- mps_word_t *string;
-
- string = alloc_string("spong", leafap);
+ (void)alloc_string("spong", leafap);
}
}
diff --git a/mps/code/finaltest.c b/mps/code/finaltest.c
index 24a6e81b9eb..79496801acb 100644
--- a/mps/code/finaltest.c
+++ b/mps/code/finaltest.c
@@ -176,13 +176,11 @@ static void *test(void *arg, size_t s)
die(mps_arena_collect(arena), "collect");
printf(" Done.\n");
while (mps_message_poll(arena)) {
- mps_word_t obj;
mps_addr_t objaddr;
cdie(mps_message_get(&message, arena,
mps_message_type_finalization()),
"get");
mps_message_finalization_ref(&objaddr, arena, message);
- obj = (mps_word_t)objaddr;
mps_message_discard(arena, message);
++ final_this_time;
}
@@ -216,13 +214,11 @@ static void *test(void *arg, size_t s)
die(mps_arena_collect(arena), "collect");
printf(" Done.\n");
while (mps_message_poll(arena)) {
- mps_word_t obj;
mps_addr_t objaddr;
cdie(mps_message_get(&message, arena,
mps_message_type_finalization()),
"get");
mps_message_finalization_ref(&objaddr, arena, message);
- obj = (mps_word_t)objaddr;
mps_message_discard(arena, message);
++ final_this_time;
}
diff --git a/mps/code/fmtdy.c b/mps/code/fmtdy.c
index ec87c1fa001..b7a2f7fa02f 100644
--- a/mps/code/fmtdy.c
+++ b/mps/code/fmtdy.c
@@ -129,24 +129,30 @@ int dylan_wrapper_check(mps_word_t *w)
/* The first field is traceable, the second field can be traced, */
/* but doesn't need to be. */
assert((ww[WP] == 1) || (ww[WP] == 3));
-
+ unused(ww);
+
/* Unpack the wrapper. */
class = w[WC]; /* class */
+ unused(class);
fh = w[WF]; /* fixed part header word */
fl = fh >> 2; /* fixed part length */
ff = fh & 3; /* fixed part format code */
vh = w[WV]; /* variable part header */
version = (vh >> (MPS_WORD_WIDTH - 8)) & 0xff;
assert(version == 2); /* Code in this file only works for version 2 */
+ unused(version);
reserved = (vh >> 8) & 0xff;
assert(reserved == 0);
+ unused(reserved);
vb = (vh >> 16) & 0xff;
+ unused(vb);
es = (vh & 0xff) >> 3;/* element size */
vf = vh & 7; /* variable part format code */
vt = w[WS]; /* vector total word (Dylan-tagged) */
t = vt >> 2; /* vector total length */
-
+ unused(t);
+
/* The second word is the class of the wrapped object. */
/* It would be good to check which pool this is in. */
@@ -160,23 +166,26 @@ int dylan_wrapper_check(mps_word_t *w)
/* Fixed part format 3 is reserved. */
assert(ff != 3);
+ unused(ff);
/* Zero length fixed part is only legal in format 0. */
/* Current Dylan run-time does not honour this so I remove it for now */
/* We probably want this check as then we can scan without having to */
/* check for 0 fixed length fields as a special case */
/* assert(ff == 0 || fl != 0); */
-
+ unused(fl);
/* The fourth word contains the variable part format and element */
/* size. This assumes that DylanWorks is only going to use byte */
/* vectors in the non-word case. */
/* Variable part format 6 is reserved. */
assert(vf != 6);
-
+ unused(vf);
+
/* There should be no shift in word vector formats. */
assert((vf & 6) == 4 || es == 0);
-
+ unused(es);
+
/* The fifth word is the number of patterns in the pattern */
/* vector. This can be calculated from the fixed part length. */
/* The word is also tagged like a DylanWorks integer. */
@@ -247,9 +256,11 @@ extern mps_addr_t dylan_weak_dependent(mps_addr_t parent)
ff = fword & 3;
/* traceable fixed part */
assert(ff == 1);
+ unused(ff);
fl = fword & ~(mps_word_t)3;
/* at least one fixed field */
assert(fl >= 1);
+ unused(fl);
return (mps_addr_t) object[1];
}
@@ -555,7 +566,8 @@ extern mps_res_t dylan_scan1_weak(mps_ss_t mps_ss, mps_addr_t *object_io)
h = (mps_word_t)p[0];
/* object should not be forwarded (as there is no forwarding method) */
assert((h & 3) == 0);
-
+ unused(h);
+
res = mps_fix(mps_ss, p);
if ( res != MPS_RES_OK ) return res;
@@ -576,7 +588,8 @@ extern mps_res_t dylan_scan1_weak(mps_ss_t mps_ss, mps_addr_t *object_io)
/* weak vectors should have traceable fixed format */
assert(ff == 1);
-
+ unused(ff);
+
assoc = (mps_addr_t *)p[0];
vword = w[WV];
@@ -585,7 +598,8 @@ extern mps_res_t dylan_scan1_weak(mps_ss_t mps_ss, mps_addr_t *object_io)
/* weak vectors should be non-stretchy traceable */
assert(vf == 2);
-
+ unused(vf);
+
/* q is end of the object. There are fl fixed fields, vl variable */
/* fields and another slot that contains the vector length */
q = p + fl + vl + 1;
diff --git a/mps/code/locus.c b/mps/code/locus.c
index 56e7a1208c6..22473026dc6 100644
--- a/mps/code/locus.c
+++ b/mps/code/locus.c
@@ -300,7 +300,8 @@ Res ChainCondemnAuto(double *mortalityReturn, Chain chain, Trace trace)
" (of $U)", (WriteFU)chain->genCount,
" of this chain $P.", (WriteFP)chain,
NULL ));
-
+ UNUSED(topCondemnedGenSerial); /* only used for DIAG */
+
/* Condemn everything in these zones. */
if (condemnedSet != ZoneSetEMPTY) {
res = TraceCondemnZones(trace, condemnedSet);
diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c
index 3614590c8a8..bea60caa03e 100644
--- a/mps/code/poolamc.c
+++ b/mps/code/poolamc.c
@@ -1583,7 +1583,6 @@ static Res amcScanNailed(Bool *totalReturn, ScanState ss, Pool pool,
static Res AMCScan(Bool *totalReturn, ScanState ss, Pool pool, Seg seg)
{
Addr base, limit;
- Arena arena;
Format format;
AMC amc;
Res res;
@@ -1597,7 +1596,6 @@ static Res AMCScan(Bool *totalReturn, ScanState ss, Pool pool, Seg seg)
format = pool->format;
- arena = pool->arena;
if(amcSegHasNailboard(seg)) {
return amcScanNailed(totalReturn, ss, pool, seg, amc);
diff --git a/mps/code/poollo.c b/mps/code/poollo.c
index 49346f4cb56..c4a5872af54 100644
--- a/mps/code/poollo.c
+++ b/mps/code/poollo.c
@@ -234,7 +234,6 @@ static Bool loSegFindFree(Addr *bReturn, Addr *lReturn,
Index baseIndex, limitIndex;
LO lo;
Seg seg;
- Arena arena;
Count agrains;
Count bits;
Addr segBase;
@@ -246,7 +245,6 @@ static Bool loSegFindFree(Addr *bReturn, Addr *lReturn,
lo = loseg->lo;
seg = LOSegSeg(loseg);
AVER(SizeIsAligned(size, LOPool(lo)->alignment));
- arena = PoolArena(LOPool(lo));
/* agrains is the number of grains corresponding to the size */
/* of the allocation request */
@@ -547,7 +545,6 @@ static Res LOBufferFill(Addr *baseReturn, Addr *limitReturn,
Ring node, nextNode;
LO lo;
LOSeg loseg;
- Arena arena;
Addr base, limit;
AVER(baseReturn != NULL);
@@ -562,8 +559,6 @@ static Res LOBufferFill(Addr *baseReturn, Addr *limitReturn,
AVER(SizeIsAligned(size, PoolAlignment(pool)));
AVER(BoolCheck(withReservoirPermit));
- arena = PoolArena(pool);
-
/* Try to find a segment with enough space already. */
RING_FOR(node, &pool->segRing, nextNode) {
Seg seg = SegOfPoolRing(node);
@@ -619,7 +614,6 @@ static void LOBufferEmpty(Pool pool, Buffer buffer, Addr init, Addr limit)
Seg seg;
LOSeg loseg;
Index baseIndex, initIndex, limitIndex;
- Arena arena;
AVERT(Pool, pool);
lo = PARENT(LOStruct, poolStruct, pool);
@@ -634,7 +628,6 @@ static void LOBufferEmpty(Pool pool, Buffer buffer, Addr init, Addr limit)
AVERT(LOSeg, loseg);
AVER(loseg->lo == lo);
- arena = PoolArena(pool);
base = BufferBase(buffer);
segBase = SegBase(seg);
diff --git a/mps/code/poolmrg.c b/mps/code/poolmrg.c
index 180a1789ca6..a8c08047821 100644
--- a/mps/code/poolmrg.c
+++ b/mps/code/poolmrg.c
@@ -477,9 +477,6 @@ static MessageClassStruct MRGMessageClassStruct = {
*/
static void MRGSegPairDestroy(MRGRefSeg refseg, MRG mrg)
{
- Pool pool;
-
- pool = MRG2Pool(mrg);
RingRemove(&refseg->mrgRing);
RingFinish(&refseg->mrgRing);
refseg->sig = SigInvalid;
diff --git a/mps/code/poolmv.c b/mps/code/poolmv.c
index 0b3d1c2d88d..ae71bb40804 100644
--- a/mps/code/poolmv.c
+++ b/mps/code/poolmv.c
@@ -824,7 +824,6 @@ size_t mps_mv_size(mps_pool_t mps_pool)
Pool pool;
MV mv;
MVSpan span;
- Arena arena;
Size f = 0;
Ring spans, node = NULL, nextNode; /* gcc whinge stop */
@@ -833,7 +832,6 @@ size_t mps_mv_size(mps_pool_t mps_pool)
AVERT(Pool, pool);
mv = Pool2MV(pool);
AVERT(MV, mv);
- arena = PoolArena(pool);
spans = &mv->spans;
RING_FOR(node, spans, nextNode) {
diff --git a/mps/code/reserv.c b/mps/code/reserv.c
index f75c64afad9..cc739291e3c 100644
--- a/mps/code/reserv.c
+++ b/mps/code/reserv.c
@@ -215,7 +215,6 @@ static void reservoirShrink(Reservoir reservoir, Size want)
Res ReservoirWithdraw(Addr *baseReturn, Tract *baseTractReturn,
Reservoir reservoir, Size size, Pool pool)
{
- Pool respool;
Arena arena;
AVER(baseReturn != NULL);
@@ -226,7 +225,6 @@ Res ReservoirWithdraw(Addr *baseReturn, Tract *baseTractReturn,
AVER(SizeIsAligned(size, ArenaAlign(arena)));
AVER(size > 0);
AVERT(Pool, pool);
- respool = &reservoir->poolStruct;
/* @@@@ As a short-term measure, we only permit the reservoir to */
/* allocate single-page regions. */
diff --git a/mps/code/seg.c b/mps/code/seg.c
index f45f5297c75..f5218b2be8d 100644
--- a/mps/code/seg.c
+++ b/mps/code/seg.c
@@ -231,8 +231,8 @@ static void SegFinish(Seg seg)
/* See */
ShieldFlush(PoolArena(SegPool(seg)));
- base = SegBase(seg);
limit = SegLimit(seg);
+
TRACT_TRACT_FOR(tract, addr, arena, seg->firstTract, limit) {
AVER(TractCheck(tract)); /* */
TractSetWhite(tract, TraceSetEMPTY);
diff --git a/mps/code/segsmss.c b/mps/code/segsmss.c
index 04fa587dee5..5a557be9c63 100644
--- a/mps/code/segsmss.c
+++ b/mps/code/segsmss.c
@@ -433,14 +433,10 @@ static Bool AMSSegRegionIsFree(Seg seg, Addr base, Addr limit)
*/
static void AMSUnallocateRange(Seg seg, Addr base, Addr limit)
{
- Pool pool;
- AMS ams;
AMSSeg amsseg;
Index baseIndex, limitIndex;
/* parameters checked by caller */
- pool = SegPool(seg);
- ams = Pool2AMS(pool);
amsseg = Seg2AMSSeg(seg);
baseIndex = AMS_ADDR_INDEX(seg, base);
@@ -475,14 +471,10 @@ static void AMSUnallocateRange(Seg seg, Addr base, Addr limit)
*/
static void AMSAllocateRange(Seg seg, Addr base, Addr limit)
{
- Pool pool;
- AMS ams;
AMSSeg amsseg;
Index baseIndex, limitIndex;
/* parameters checked by caller */
- pool = SegPool(seg);
- ams = Pool2AMS(pool);
amsseg = Seg2AMSSeg(seg);
baseIndex = AMS_ADDR_INDEX(seg, base);