Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0e85abd

Browse files
committed
Clean up compiler warnings from unused variables with asserts disabled
For those variables only used when asserts are enabled, use a newmacro PG_USED_FOR_ASSERTS_ONLY, which expands to__attribute__((unused)) when asserts are not enabled.
1 parent621eb15 commit0e85abd

File tree

15 files changed

+29
-19
lines changed

15 files changed

+29
-19
lines changed

‎src/backend/access/hash/hashovfl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf,
391391
uint32ovflbitno;
392392
int32bitmappage,
393393
bitmapbit;
394-
Bucketbucket;
394+
BucketbucketPG_USED_FOR_ASSERTS_ONLY;
395395

396396
/* Get information from the doomed page */
397397
_hash_checkpage(rel,ovflbuf,LH_OVERFLOW_PAGE);

‎src/backend/executor/execCurrent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ execCurrentOf(CurrentOfExpr *cexpr,
151151
{
152152
ScanState*scanstate;
153153
boollisnull;
154-
Oidtuple_tableoid;
154+
Oidtuple_tableoidPG_USED_FOR_ASSERTS_ONLY;
155155
ItemPointertuple_tid;
156156

157157
/*

‎src/backend/executor/nodeMaterial.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ ExecMaterial(MaterialState *node)
6666
* Allocate a second read pointer to serve as the mark. We know it
6767
* must have index 1, so needn't store that.
6868
*/
69-
intptrno;
69+
intptrnoPG_USED_FOR_ASSERTS_ONLY;
7070

7171
ptrno=tuplestore_alloc_read_pointer(tuplestorestate,
7272
node->eflags);

‎src/backend/executor/nodeSetOp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ setop_fill_hash_table(SetOpState *setopstate)
344344
SetOp*node= (SetOp*)setopstate->ps.plan;
345345
PlanState*outerPlan;
346346
intfirstFlag;
347-
boolin_first_rel;
347+
boolin_first_relPG_USED_FOR_ASSERTS_ONLY;
348348

349349
/*
350350
* get state info from node

‎src/backend/executor/nodeWorktablescan.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ static TupleTableSlot *
3030
WorkTableScanNext(WorkTableScanState*node)
3131
{
3232
TupleTableSlot*slot;
33-
EState*estate;
3433
Tuplestorestate*tuplestorestate;
3534

3635
/*
@@ -48,8 +47,7 @@ WorkTableScanNext(WorkTableScanState *node)
4847
* worktable. Therefore, we don't need a private read pointer for the
4948
* tuplestore, nor do we need to tell tuplestore_gettupleslot to copy.
5049
*/
51-
estate=node->ss.ps.state;
52-
Assert(ScanDirectionIsForward(estate->es_direction));
50+
Assert(ScanDirectionIsForward(node->ss.ps.state->es_direction));
5351

5452
tuplestorestate=node->rustate->working_table;
5553

‎src/backend/libpq/be-fsstubs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ lo_import_internal(text *filename, Oid lobjOid)
378378
{
379379
Filefd;
380380
intnbytes,
381-
tmp;
381+
tmpPG_USED_FOR_ASSERTS_ONLY;
382382
charbuf[BUFSIZE];
383383
charfnamebuf[MAXPGPATH];
384384
LargeObjectDesc*lobj;

‎src/backend/libpq/pqcomm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ pq_putmessage(char msgtype, const char *s, size_t len)
13731373
void
13741374
pq_putmessage_noblock(charmsgtype,constchar*s,size_tlen)
13751375
{
1376-
intres;
1376+
intresPG_USED_FOR_ASSERTS_ONLY;
13771377
intrequired;
13781378

13791379
/*

‎src/backend/optimizer/path/costsize.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3583,7 +3583,7 @@ void
35833583
set_subquery_size_estimates(PlannerInfo*root,RelOptInfo*rel)
35843584
{
35853585
PlannerInfo*subroot=rel->subroot;
3586-
RangeTblEntry*rte;
3586+
RangeTblEntry*rtePG_USED_FOR_ASSERTS_ONLY;
35873587
ListCell*lc;
35883588

35893589
/* Should only be applied to base relations that are subqueries */

‎src/backend/parser/analyze.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
15881588
/* Process leaf SELECT */
15891589
Query*selectQuery;
15901590
charselectName[32];
1591-
RangeTblEntry*rte;
1591+
RangeTblEntry*rtePG_USED_FOR_ASSERTS_ONLY;
15921592
RangeTblRef*rtr;
15931593
ListCell*tl;
15941594

‎src/backend/storage/file/fd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ LruInsert(File file)
685685
/* seek to the right position */
686686
if (vfdP->seekPos!= (off_t)0)
687687
{
688-
off_treturnValue;
688+
off_treturnValuePG_USED_FOR_ASSERTS_ONLY;
689689

690690
returnValue=lseek(vfdP->fd,vfdP->seekPos,SEEK_SET);
691691
Assert(returnValue!= (off_t)-1);

‎src/backend/storage/lmgr/predicate.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,7 @@ RestoreScratchTarget(bool lockheld)
20132013
staticvoid
20142014
RemoveTargetIfNoLongerUsed(PREDICATELOCKTARGET*target,uint32targettaghash)
20152015
{
2016-
PREDICATELOCKTARGET*rmtarget;
2016+
PREDICATELOCKTARGET*rmtargetPG_USED_FOR_ASSERTS_ONLY;
20172017

20182018
Assert(LWLockHeldByMe(SerializablePredicateLockListLock));
20192019

@@ -2074,7 +2074,7 @@ DeleteChildTargetLocks(const PREDICATELOCKTARGETTAG *newtargettag)
20742074
{
20752075
uint32oldtargettaghash;
20762076
LWLockIdpartitionLock;
2077-
PREDICATELOCK*rmpredlock;
2077+
PREDICATELOCK*rmpredlockPG_USED_FOR_ASSERTS_ONLY;
20782078

20792079
oldtargettaghash=PredicateLockTargetTagHashCode(&oldtargettag);
20802080
partitionLock=PredicateLockHashPartitionLock(oldtargettaghash);
@@ -2227,7 +2227,7 @@ DecrementParentLocks(const PREDICATELOCKTARGETTAG *targettag)
22272227
{
22282228
uint32targettaghash;
22292229
LOCALPREDICATELOCK*parentlock,
2230-
*rmlock;
2230+
*rmlockPG_USED_FOR_ASSERTS_ONLY;
22312231

22322232
parenttag=nexttag;
22332233
targettaghash=PredicateLockTargetTagHashCode(&parenttag);

‎src/backend/storage/lmgr/proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ static void
808808
AuxiliaryProcKill(intcode,Datumarg)
809809
{
810810
intproctype=DatumGetInt32(arg);
811-
PGPROC*auxproc;
811+
PGPROC*auxprocPG_USED_FOR_ASSERTS_ONLY;
812812

813813
Assert(proctype >=0&&proctype<NUM_AUXILIARY_PROCS);
814814

‎src/backend/utils/adt/selfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3874,7 +3874,7 @@ convert_string_datum(Datum value, Oid typid)
38743874
{
38753875
char*xfrmstr;
38763876
size_txfrmlen;
3877-
size_txfrmlen2;
3877+
size_txfrmlen2PG_USED_FOR_ASSERTS_ONLY;
38783878

38793879
/*
38803880
* Note: originally we guessed at a suitable output buffer size, and
@@ -6408,7 +6408,7 @@ btcostestimate(PG_FUNCTION_ARGS)
64086408
RestrictInfo*rinfo= (RestrictInfo*)lfirst(lcc);
64096409
Expr*clause;
64106410
Node*leftop,
6411-
*rightop;
6411+
*rightopPG_USED_FOR_ASSERTS_ONLY;
64126412
Oidclause_op;
64136413
intop_strategy;
64146414
boolis_null_op= false;

‎src/bin/psql/psqlscan.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ psql_scan_slash_option(PsqlScanState state,
14741474
bool semicolon)
14751475
{
14761476
PQExpBufferData mybuf;
1477-
intlexresult;
1477+
intlexresult PG_USED_FOR_ASSERTS_ONLY;
14781478
charlocal_quote;
14791479
14801480
/* Must be scanning already */

‎src/include/c.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,18 @@ typedef NameData *Name;
710710
#defineSTATUS_WAITING(2)
711711

712712

713+
/*
714+
* Append PG_USED_FOR_ASSERTS_ONLY to definitions of variables that are only
715+
* used in assert-enabled builds, to avoid compiler warnings about unused
716+
* variables in assert-disabled builds.
717+
*/
718+
#ifdefUSE_ASSERT_CHECKING
719+
#definePG_USED_FOR_ASSERTS_ONLY
720+
#else
721+
#definePG_USED_FOR_ASSERTS_ONLY __attribute__((unused))
722+
#endif
723+
724+
713725
/* gettext domain name mangling */
714726

715727
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp