diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c index f89769f379..04b27f1e6e 100644 --- a/src/backend/access/common/heaptuple.c +++ b/src/backend/access/common/heaptuple.c @@ -736,7 +736,6 @@ expand_tuple(HeapTuple *targetHeapTuple, { AttrMissing *attrmiss = NULL; int attnum; - int firstmissingnum = 0; bool hasNulls = HeapTupleHasNulls(sourceTuple); HeapTupleHeader targetTHeader; HeapTupleHeader sourceTHeader = sourceTuple->t_data; @@ -765,6 +764,8 @@ expand_tuple(HeapTuple *targetHeapTuple, if (tupleDesc->constr && tupleDesc->constr->missing) { + int firstmissingnum; + /* * If there are missing values we want to put them into the tuple. * Before that we have to compute the extra length for the values diff --git a/src/backend/access/gin/ginbtree.c b/src/backend/access/gin/ginbtree.c index 8d08b05f51..82788a5c36 100644 --- a/src/backend/access/gin/ginbtree.c +++ b/src/backend/access/gin/ginbtree.c @@ -241,7 +241,6 @@ ginFindParents(GinBtree btree, GinBtreeStack *stack) blkno = root->blkno; buffer = root->buffer; - offset = InvalidOffsetNumber; ptr = (GinBtreeStack *) palloc(sizeof(GinBtreeStack)); diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c index dd975b164c..cc126236a1 100644 --- a/src/backend/access/gist/gistutil.c +++ b/src/backend/access/gist/gistutil.c @@ -32,7 +32,7 @@ void gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off) { - OffsetNumber l = InvalidOffsetNumber; + OffsetNumber l; int i; if (off == InvalidOffsetNumber) diff --git a/src/backend/access/hash/hashsearch.c b/src/backend/access/hash/hashsearch.c index 995498e48d..d56ffe3b3e 100644 --- a/src/backend/access/hash/hashsearch.c +++ b/src/backend/access/hash/hashsearch.c @@ -470,7 +470,7 @@ _hash_readpage(IndexScanDesc scan, Buffer *bufP, ScanDirection dir) if (ScanDirectionIsForward(dir)) { - BlockNumber prev_blkno = InvalidBlockNumber; + BlockNumber prev_blkno; for (;;) { diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c index 8ff49ce6d6..32e80337b0 100644 --- a/src/backend/access/nbtree/nbtsearch.c +++ b/src/backend/access/nbtree/nbtsearch.c @@ -1863,7 +1863,7 @@ _bt_steppage(IndexScanDesc scan, ScanDirection dir) { BTScanOpaque so = (BTScanOpaque) scan->opaque; BlockNumber blkno = InvalidBlockNumber; - bool status = true; + bool status; Assert(BTScanPosIsValid(so->currPos)); @@ -1972,7 +1972,7 @@ _bt_readnextpage(IndexScanDesc scan, BlockNumber blkno, ScanDirection dir) Relation rel; Page page; BTPageOpaque opaque; - bool status = true; + bool status; rel = scan->indexRelation; diff --git a/src/backend/access/nbtree/nbtsplitloc.c b/src/backend/access/nbtree/nbtsplitloc.c index 8ba055be9e..15ac106525 100644 --- a/src/backend/access/nbtree/nbtsplitloc.c +++ b/src/backend/access/nbtree/nbtsplitloc.c @@ -812,7 +812,6 @@ _bt_bestsplitloc(FindSplitData *state, int perfectpenalty, if (penalty <= perfectpenalty) { - bestpenalty = penalty; lowsplit = i; break; } diff --git a/src/backend/access/spgist/spgtextproc.c b/src/backend/access/spgist/spgtextproc.c index b5ec81937c..08972e83c6 100644 --- a/src/backend/access/spgist/spgtextproc.c +++ b/src/backend/access/spgist/spgtextproc.c @@ -187,7 +187,6 @@ spg_text_choose(PG_FUNCTION_ARGS) char *inStr = VARDATA_ANY(inText); int inSize = VARSIZE_ANY_EXHDR(inText); char *prefixStr = NULL; - int prefixSize = 0; int commonLen = 0; int16 nodeChar = 0; int i = 0; @@ -196,6 +195,7 @@ spg_text_choose(PG_FUNCTION_ARGS) if (in->hasPrefix) { text *prefixText = DatumGetTextPP(in->prefixDatum); + int prefixSize; prefixStr = VARDATA_ANY(prefixText); prefixSize = VARSIZE_ANY_EXHDR(prefixText); diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 7621fc05e2..1491b047ed 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -10825,7 +10825,6 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p) FILE *fp; char ch; int seconds_before_warning; - int waits = 0; bool reported_waiting = false; char *remaining; char *ptr; @@ -11146,6 +11145,8 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p) ((!backup_started_in_recovery && XLogArchivingActive()) || (backup_started_in_recovery && XLogArchivingAlways()))) { + int waits; + XLByteToPrevSeg(stoppoint, _logSegNo, wal_segment_size); XLogFileName(lastxlogfilename, stoptli, _logSegNo, wal_segment_size); diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c index fddfbf1d8c..3f48a44e66 100644 --- a/src/backend/catalog/storage.c +++ b/src/backend/catalog/storage.c @@ -434,7 +434,6 @@ smgrDoPendingDeletes(bool isCommit) PendingRelDelete *prev; PendingRelDelete *next; int nrels = 0, - i = 0, maxrels = 0; SMgrRelation *srels = NULL; @@ -483,6 +482,8 @@ smgrDoPendingDeletes(bool isCommit) if (nrels > 0) { + int i; + smgrdounlinkall(srels, nrels, false); for (i = 0; i < nrels; i++) diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index c1911411d0..37e8a61c4b 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -1633,12 +1633,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx, if (AttributeNumberIsValid(attnum)) { /* Simple index column */ - char *attname; - - attname = get_attname(indrelid, attnum, false); - keycoltype = get_atttype(indrelid, attnum); - - iparam->name = attname; + iparam->name = get_attname(indrelid, attnum, false); iparam->expr = NULL; } else diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c index ffcb54968f..1dd57d9162 100644 --- a/src/backend/postmaster/syslogger.c +++ b/src/backend/postmaster/syslogger.c @@ -878,7 +878,7 @@ process_pipe_input(char *logbuffer, int *bytes_in_logbuffer) { char *cursor = logbuffer; int count = *bytes_in_logbuffer; - int dest = LOG_DESTINATION_STDERR; + int dest; /* While we have enough for a header, process data... */ while (count >= (int) (offsetof(PipeProtoHeader, data) + 1)) diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index f45a619deb..df4030f626 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -2821,7 +2821,6 @@ CancelDBBackends(Oid databaseid, ProcSignalReason sigmode, bool conflictPending) { ProcArrayStruct *arrayP = procArray; int index; - pid_t pid = 0; /* tell all backends to die */ LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); @@ -2834,6 +2833,7 @@ CancelDBBackends(Oid databaseid, ProcSignalReason sigmode, bool conflictPending) if (databaseid == InvalidOid || proc->databaseId == databaseid) { VirtualTransactionId procvxid; + pid_t pid; GET_VXID_FROM_PGPROC(procvxid, *proc); diff --git a/src/backend/tsearch/spell.c b/src/backend/tsearch/spell.c index 8aab96d3b0..7091fb8e04 100644 --- a/src/backend/tsearch/spell.c +++ b/src/backend/tsearch/spell.c @@ -1710,7 +1710,6 @@ void NISortDictionary(IspellDict *Conf) { int i; - int naffix = 0; int curaffix; /* compress affixes */ @@ -1760,6 +1759,8 @@ NISortDictionary(IspellDict *Conf) /* Otherwise fill Conf->AffixData here */ else { + int naffix; + /* Count the number of different flags used in the dictionary */ qsort((void *) Conf->Spell, Conf->nspell, sizeof(SPELL *), cmpspellaffix); @@ -1879,7 +1880,6 @@ mkANode(IspellDict *Conf, int low, int high, int level, int type) data->naff = naff; data->aff = (AFFIX **) cpalloc(sizeof(AFFIX *) * naff); memcpy(data->aff, aff, sizeof(AFFIX *) * naff); - naff = 0; } pfree(aff); @@ -2124,7 +2124,6 @@ CheckAffix(const char *word, size_t len, AFFIX *Affix, int flagflags, char *neww } else { - int err; pg_wchar *data; size_t data_len; int newword_len; @@ -2134,7 +2133,7 @@ CheckAffix(const char *word, size_t len, AFFIX *Affix, int flagflags, char *neww data = (pg_wchar *) palloc((newword_len + 1) * sizeof(pg_wchar)); data_len = pg_mb2wchar_with_len(newword, data, newword_len); - if (!(err = pg_regexec(&(Affix->reg.regex), data, data_len, 0, NULL, 0, NULL, 0))) + if (!pg_regexec(&(Affix->reg.regex), data, data_len, 0, NULL, 0, NULL, 0)) { pfree(data); return newword; diff --git a/src/backend/tsearch/to_tsany.c b/src/backend/tsearch/to_tsany.c index e7cd6264db..3304066b94 100644 --- a/src/backend/tsearch/to_tsany.c +++ b/src/backend/tsearch/to_tsany.c @@ -480,13 +480,7 @@ add_to_tsvector(void *_state, char *elem_value, int elem_len) static void pushval_morph(Datum opaque, TSQueryParserState state, char *strval, int lenval, int16 weight, bool prefix) { - int32 count = 0; ParsedText prs; - uint32 variant, - pos = 0, - cntvar = 0, - cntpos = 0, - cnt = 0; MorphOpaque *data = (MorphOpaque *) DatumGetPointer(opaque); prs.lenwords = 4; @@ -498,6 +492,13 @@ pushval_morph(Datum opaque, TSQueryParserState state, char *strval, int lenval, if (prs.curwords > 0) { + int32 count = 0; + uint32 variant, + pos = 0, + cntvar = 0, + cntpos = 0, + cnt = 0; + while (count < prs.curwords) { /* diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c index 898466fcef..66eeb55993 100644 --- a/src/backend/tsearch/wparser_def.c +++ b/src/backend/tsearch/wparser_def.c @@ -2133,8 +2133,8 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight, maxstretch, posmarker; - int32 startpos = 0, - endpos = 0, + int32 startpos, + endpos, p = 0, q = 0; diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 7a4a5aaa86..e2a1d06bc5 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -2787,7 +2787,6 @@ array_set_slice(Datum arraydatum, overheadlen, oldoverheadlen, addedbefore, - addedafter, lenbefore, lenafter, itemsbefore, @@ -2865,7 +2864,7 @@ array_set_slice(Datum arraydatum, memcpy(lb, ARR_LBOUND(array), ndim * sizeof(int)); newhasnulls = (ARR_HASNULL(array) || ARR_HASNULL(srcArray)); - addedbefore = addedafter = 0; + addedbefore = 0; /* * Check subscripts @@ -2893,8 +2892,7 @@ array_set_slice(Datum arraydatum, { if (lowerIndx[0] > (dim[0] + lb[0])) newhasnulls = true; /* will insert nulls */ - addedafter = upperIndx[0] - (dim[0] + lb[0]) + 1; - dim[0] += addedafter; + dim[0] += upperIndx[0] - (dim[0] + lb[0]) + 1; } } else diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 95f7d0538e..2a30ae4c69 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -4931,7 +4931,7 @@ static char * int_to_roman(int number) { int len = 0, - num = 0; + num; char *p = NULL, *result, numstr[12]; diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c index f4b0200f1e..e680f649ef 100644 --- a/src/backend/utils/adt/tsrank.c +++ b/src/backend/utils/adt/tsrank.c @@ -854,7 +854,7 @@ calc_rank_cd(const float4 *arrdata, TSVector txt, TSQuery query, int method) double invws[lengthof(weights)]; double SumDist = 0.0, PrevExtPos = 0.0, - CurExtPos = 0.0; + CurExtPos; int NExtent = 0; QueryRepresentation qr; diff --git a/src/backend/utils/adt/tsvector_op.c b/src/backend/utils/adt/tsvector_op.c index 24525879b7..89913ad8fb 100644 --- a/src/backend/utils/adt/tsvector_op.c +++ b/src/backend/utils/adt/tsvector_op.c @@ -1263,7 +1263,7 @@ checkcondition_str(void *checkval, QueryOperand *val, ExecPhraseData *data) WordEntry *StopLow = chkval->arrb; WordEntry *StopHigh = chkval->arre; WordEntry *StopMiddle = StopHigh; - int difference = -1; + int difference; bool res = false; /* Loop invariant: StopLow <= val < StopHigh */ diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index d02e676aa3..ab84297975 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -2565,7 +2565,6 @@ mergeruns(Tuplesortstate *state) svTape, svRuns, svDummy; - int numTapes; int numInputTapes; Assert(state->status == TSS_BUILDRUNS); @@ -2606,7 +2605,7 @@ mergeruns(Tuplesortstate *state) * If we had fewer runs than tapes, refund the memory that we imagined we * would need for the tape buffers of the unused tapes. * - * numTapes and numInputTapes reflect the actual number of tapes we will + * numInputTapes reflect the actual number of tapes we will * use. Note that the output tape's tape number is maxTapes - 1, so the * tape numbers of the used tapes are not consecutive, and you cannot just * loop from 0 to numTapes to visit all used tapes! @@ -2614,13 +2613,11 @@ mergeruns(Tuplesortstate *state) if (state->Level == 1) { numInputTapes = state->currentRun; - numTapes = numInputTapes + 1; - FREEMEM(state, (state->maxTapes - numTapes) * TAPE_BUFFER_OVERHEAD); + FREEMEM(state, (state->maxTapes - numInputTapes + 1) * TAPE_BUFFER_OVERHEAD); } else { numInputTapes = state->tapeRange; - numTapes = state->maxTapes; } /*