Commit a5cc4dab authored by Tom Lane's avatar Tom Lane

Yet more elimination of dead stores and useless initializations.

I'm not sure what tool Ranier was using, but the ones I contributed
were found by using a newer version of scan-build than I tried before.

Ranier Vilela and Tom Lane

Discussion: https://postgr.es/m/CAEudQAo1+AcGppxDSg8k+zF4+Kv+eJyqzEDdbpDg58-=MQcerQ@mail.gmail.com
parent 8febfd18
......@@ -736,7 +736,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
{
AttrMissing *attrmiss = NULL;
int attnum;
int firstmissingnum = 0;
int firstmissingnum;
bool hasNulls = HeapTupleHasNulls(sourceTuple);
HeapTupleHeader targetTHeader;
HeapTupleHeader sourceTHeader = sourceTuple->t_data;
......
......@@ -32,7 +32,6 @@
void
gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off)
{
OffsetNumber l = InvalidOffsetNumber;
int i;
if (off == InvalidOffsetNumber)
......@@ -42,6 +41,7 @@ gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off)
for (i = 0; i < len; i++)
{
Size sz = IndexTupleSize(itup[i]);
OffsetNumber l;
l = PageAddItem(page, (Item) itup[i], sz, off, false, false);
if (l == InvalidOffsetNumber)
......
......@@ -860,7 +860,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
ScanKeyData notnullkeys[INDEX_MAX_KEYS];
int keysCount = 0;
int i;
bool status = true;
bool status;
StrategyNumber strat_total;
BTScanPosItem *currItem;
BlockNumber blkno;
......@@ -1858,7 +1858,7 @@ _bt_steppage(IndexScanDesc scan, ScanDirection dir)
{
BTScanOpaque so = (BTScanOpaque) scan->opaque;
BlockNumber blkno = InvalidBlockNumber;
bool status = true;
bool status;
Assert(BTScanPosIsValid(so->currPos));
......@@ -1967,7 +1967,7 @@ _bt_readnextpage(IndexScanDesc scan, BlockNumber blkno, ScanDirection dir)
Relation rel;
Page page;
BTPageOpaque opaque;
bool status = true;
bool status;
rel = scan->indexRelation;
......
......@@ -599,7 +599,6 @@ smgrDoPendingDeletes(bool isCommit)
PendingRelDelete *prev;
PendingRelDelete *next;
int nrels = 0,
i = 0,
maxrels = 0;
SMgrRelation *srels = NULL;
......@@ -650,7 +649,7 @@ smgrDoPendingDeletes(bool isCommit)
{
smgrdounlinkall(srels, nrels, false);
for (i = 0; i < nrels; i++)
for (int i = 0; i < nrels; i++)
smgrclose(srels[i]);
pfree(srels);
......
......@@ -1918,7 +1918,6 @@ static void
asyncQueueReadAllNotifications(void)
{
volatile QueuePosition pos;
QueuePosition oldpos;
QueuePosition head;
Snapshot snapshot;
......@@ -1933,7 +1932,7 @@ asyncQueueReadAllNotifications(void)
LWLockAcquire(NotifyQueueLock, LW_SHARED);
/* Assert checks that we have a valid state entry */
Assert(MyProcPid == QUEUE_BACKEND_PID(MyBackendId));
pos = oldpos = QUEUE_BACKEND_POS(MyBackendId);
pos = QUEUE_BACKEND_POS(MyBackendId);
head = QUEUE_HEAD;
LWLockRelease(NotifyQueueLock);
......
......@@ -3433,7 +3433,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);
......@@ -3446,6 +3445,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);
......
......@@ -1710,7 +1710,7 @@ void
NISortDictionary(IspellDict *Conf)
{
int i;
int naffix = 0;
int naffix;
int curaffix;
/* compress affixes */
......
......@@ -1510,8 +1510,7 @@ static const char *
get_th(char *num, int type)
{
int len = strlen(num),
last,
seclast;
last;
last = *(num + (len - 1));
if (!isdigit((unsigned char) last))
......@@ -1523,7 +1522,7 @@ get_th(char *num, int type)
* All "teens" (<x>1[0-9]) get 'TH/th', while <x>[02-9][123] still get
* 'ST/st', 'ND/nd', 'RD/rd', respectively
*/
if ((len > 1) && ((seclast = num[len - 2]) == '1'))
if ((len > 1) && (num[len - 2] == '1'))
last = 0;
switch (last)
......@@ -4932,9 +4931,9 @@ NUM_cache(int len, NUMDesc *Num, text *pars_str, bool *shouldFree)
static char *
int_to_roman(int number)
{
int len = 0,
num = 0;
char *p = NULL,
int len,
num;
char *p,
*result,
numstr[12];
......@@ -4950,7 +4949,7 @@ int_to_roman(int number)
for (p = numstr; *p != '\0'; p++, --len)
{
num = *p - 49; /* 48 ascii + 1 */
num = *p - ('0' + 1);
if (num < 0)
continue;
......@@ -6118,7 +6117,7 @@ numeric_to_char(PG_FUNCTION_ARGS)
x = DatumGetNumeric(DirectFunctionCall2(numeric_round,
NumericGetDatum(value),
Int32GetDatum(0)));
numstr = orgnum =
numstr =
int_to_roman(DatumGetInt32(DirectFunctionCall1(numeric_int4,
NumericGetDatum(x))));
}
......@@ -6239,7 +6238,7 @@ int4_to_char(PG_FUNCTION_ARGS)
* On DateType depend part (int32)
*/
if (IS_ROMAN(&Num))
numstr = orgnum = int_to_roman(value);
numstr = int_to_roman(value);
else if (IS_EEEE(&Num))
{
/* we can do it easily because float8 won't lose any precision */
......@@ -6335,7 +6334,7 @@ int8_to_char(PG_FUNCTION_ARGS)
if (IS_ROMAN(&Num))
{
/* Currently don't support int8 conversion to roman... */
numstr = orgnum = int_to_roman(DatumGetInt32(DirectFunctionCall1(int84, Int64GetDatum(value))));
numstr = int_to_roman(DatumGetInt32(DirectFunctionCall1(int84, Int64GetDatum(value))));
}
else if (IS_EEEE(&Num))
{
......
......@@ -857,8 +857,7 @@ calc_rank_cd(const float4 *arrdata, TSVector txt, TSQuery query, int method)
double Wdoc = 0.0;
double invws[lengthof(weights)];
double SumDist = 0.0,
PrevExtPos = 0.0,
CurExtPos = 0.0;
PrevExtPos = 0.0;
int NExtent = 0;
QueryRepresentation qr;
......@@ -889,6 +888,7 @@ calc_rank_cd(const float4 *arrdata, TSVector txt, TSQuery query, int method)
{
double Cpos = 0.0;
double InvSum = 0.0;
double CurExtPos;
int nNoise;
DocRepresentation *ptr = ext.begin;
......
......@@ -619,7 +619,6 @@ _skipData(ArchiveHandle *AH)
size_t blkLen;
char *buf = NULL;
int buflen = 0;
size_t cnt;
blkLen = ReadInt(AH);
while (blkLen != 0)
......@@ -638,7 +637,7 @@ _skipData(ArchiveHandle *AH)
buf = (char *) pg_malloc(blkLen);
buflen = blkLen;
}
if ((cnt = fread(buf, 1, blkLen, AH->FH)) != blkLen)
if (fread(buf, 1, blkLen, AH->FH) != blkLen)
{
if (feof(AH->FH))
fatal("could not read from input file: end of file");
......@@ -664,9 +663,7 @@ _skipData(ArchiveHandle *AH)
static int
_WriteByte(ArchiveHandle *AH, const int i)
{
int res;
if ((res = fputc(i, AH->FH)) == EOF)
if (fputc(i, AH->FH) == EOF)
WRITE_ERROR_EXIT;
return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment