Clean up compiler warnings from unused variables with asserts disabled

For those variables only used when asserts are enabled, use a new
macro PG_USED_FOR_ASSERTS_ONLY, which expands to
__attribute__((unused)) when asserts are not enabled.
This commit is contained in:
Peter Eisentraut 2012-03-21 23:30:14 +02:00
parent 621eb156f1
commit 0e85abd658
15 changed files with 29 additions and 19 deletions

View File

@ -391,7 +391,7 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf,
uint32 ovflbitno;
int32 bitmappage,
bitmapbit;
Bucket bucket;
Bucket bucket PG_USED_FOR_ASSERTS_ONLY;
/* Get information from the doomed page */
_hash_checkpage(rel, ovflbuf, LH_OVERFLOW_PAGE);

View File

@ -151,7 +151,7 @@ execCurrentOf(CurrentOfExpr *cexpr,
{
ScanState *scanstate;
bool lisnull;
Oid tuple_tableoid;
Oid tuple_tableoid PG_USED_FOR_ASSERTS_ONLY;
ItemPointer tuple_tid;
/*

View File

@ -66,7 +66,7 @@ ExecMaterial(MaterialState *node)
* Allocate a second read pointer to serve as the mark. We know it
* must have index 1, so needn't store that.
*/
int ptrno;
int ptrno PG_USED_FOR_ASSERTS_ONLY;
ptrno = tuplestore_alloc_read_pointer(tuplestorestate,
node->eflags);

View File

@ -344,7 +344,7 @@ setop_fill_hash_table(SetOpState *setopstate)
SetOp *node = (SetOp *) setopstate->ps.plan;
PlanState *outerPlan;
int firstFlag;
bool in_first_rel;
bool in_first_rel PG_USED_FOR_ASSERTS_ONLY;
/*
* get state info from node

View File

@ -30,7 +30,6 @@ static TupleTableSlot *
WorkTableScanNext(WorkTableScanState *node)
{
TupleTableSlot *slot;
EState *estate;
Tuplestorestate *tuplestorestate;
/*
@ -48,8 +47,7 @@ WorkTableScanNext(WorkTableScanState *node)
* worktable. Therefore, we don't need a private read pointer for the
* tuplestore, nor do we need to tell tuplestore_gettupleslot to copy.
*/
estate = node->ss.ps.state;
Assert(ScanDirectionIsForward(estate->es_direction));
Assert(ScanDirectionIsForward(node->ss.ps.state->es_direction));
tuplestorestate = node->rustate->working_table;

View File

@ -378,7 +378,7 @@ lo_import_internal(text *filename, Oid lobjOid)
{
File fd;
int nbytes,
tmp;
tmp PG_USED_FOR_ASSERTS_ONLY;
char buf[BUFSIZE];
char fnamebuf[MAXPGPATH];
LargeObjectDesc *lobj;

View File

@ -1373,7 +1373,7 @@ fail:
void
pq_putmessage_noblock(char msgtype, const char *s, size_t len)
{
int res;
int res PG_USED_FOR_ASSERTS_ONLY;
int required;
/*

View File

@ -3583,7 +3583,7 @@ void
set_subquery_size_estimates(PlannerInfo *root, RelOptInfo *rel)
{
PlannerInfo *subroot = rel->subroot;
RangeTblEntry *rte;
RangeTblEntry *rte PG_USED_FOR_ASSERTS_ONLY;
ListCell *lc;
/* Should only be applied to base relations that are subqueries */

View File

@ -1588,7 +1588,7 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
/* Process leaf SELECT */
Query *selectQuery;
char selectName[32];
RangeTblEntry *rte;
RangeTblEntry *rte PG_USED_FOR_ASSERTS_ONLY;
RangeTblRef *rtr;
ListCell *tl;

View File

@ -685,7 +685,7 @@ LruInsert(File file)
/* seek to the right position */
if (vfdP->seekPos != (off_t) 0)
{
off_t returnValue;
off_t returnValue PG_USED_FOR_ASSERTS_ONLY;
returnValue = lseek(vfdP->fd, vfdP->seekPos, SEEK_SET);
Assert(returnValue != (off_t) -1);

View File

@ -2013,7 +2013,7 @@ RestoreScratchTarget(bool lockheld)
static void
RemoveTargetIfNoLongerUsed(PREDICATELOCKTARGET *target, uint32 targettaghash)
{
PREDICATELOCKTARGET *rmtarget;
PREDICATELOCKTARGET *rmtarget PG_USED_FOR_ASSERTS_ONLY;
Assert(LWLockHeldByMe(SerializablePredicateLockListLock));
@ -2074,7 +2074,7 @@ DeleteChildTargetLocks(const PREDICATELOCKTARGETTAG *newtargettag)
{
uint32 oldtargettaghash;
LWLockId partitionLock;
PREDICATELOCK *rmpredlock;
PREDICATELOCK *rmpredlock PG_USED_FOR_ASSERTS_ONLY;
oldtargettaghash = PredicateLockTargetTagHashCode(&oldtargettag);
partitionLock = PredicateLockHashPartitionLock(oldtargettaghash);
@ -2227,7 +2227,7 @@ DecrementParentLocks(const PREDICATELOCKTARGETTAG *targettag)
{
uint32 targettaghash;
LOCALPREDICATELOCK *parentlock,
*rmlock;
*rmlock PG_USED_FOR_ASSERTS_ONLY;
parenttag = nexttag;
targettaghash = PredicateLockTargetTagHashCode(&parenttag);

View File

@ -808,7 +808,7 @@ static void
AuxiliaryProcKill(int code, Datum arg)
{
int proctype = DatumGetInt32(arg);
PGPROC *auxproc;
PGPROC *auxproc PG_USED_FOR_ASSERTS_ONLY;
Assert(proctype >= 0 && proctype < NUM_AUXILIARY_PROCS);

View File

@ -3874,7 +3874,7 @@ convert_string_datum(Datum value, Oid typid)
{
char *xfrmstr;
size_t xfrmlen;
size_t xfrmlen2;
size_t xfrmlen2 PG_USED_FOR_ASSERTS_ONLY;
/*
* Note: originally we guessed at a suitable output buffer size, and
@ -6408,7 +6408,7 @@ btcostestimate(PG_FUNCTION_ARGS)
RestrictInfo *rinfo = (RestrictInfo *) lfirst(lcc);
Expr *clause;
Node *leftop,
*rightop;
*rightop PG_USED_FOR_ASSERTS_ONLY;
Oid clause_op;
int op_strategy;
bool is_null_op = false;

View File

@ -1474,7 +1474,7 @@ psql_scan_slash_option(PsqlScanState state,
bool semicolon)
{
PQExpBufferData mybuf;
int lexresult;
int lexresult PG_USED_FOR_ASSERTS_ONLY;
char local_quote;
/* Must be scanning already */

View File

@ -710,6 +710,18 @@ typedef NameData *Name;
#define STATUS_WAITING (2)
/*
* Append PG_USED_FOR_ASSERTS_ONLY to definitions of variables that are only
* used in assert-enabled builds, to avoid compiler warnings about unused
* variables in assert-disabled builds.
*/
#ifdef USE_ASSERT_CHECKING
#define PG_USED_FOR_ASSERTS_ONLY
#else
#define PG_USED_FOR_ASSERTS_ONLY __attribute__((unused))
#endif
/* gettext domain name mangling */
/*