[PATCH'] Variables assigned with values that is never used.

Поиск
Список
Период
Сортировка
Искать

[PATCH'] Variables assigned with values that is never used.

От:
Ranier Vilela <ranier.vf@gmail.com>
Дата:
Вложения:
Hi,

Theses variables, are assigned with values that never is used and, can safely have their values removed.

best regards,
Ranier Vilela

Re: [PATCH'] Variables assigned with values that is never used.

От:
Ranier Vilela <ranier.vf@gmail.com>
Дата:
Em sáb., 28 de mar. de 2020 às 10:33, Ranier Vilela <ranier.vf@gmail.com> escreveu:
Hi,

Theses variables, are assigned with values that never is used and, can safely have their values removed.

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;
  }

Coincidence? I think not.

regards,
Ranier Vilela

Re: [PATCH'] Variables assigned with values that is never used.

От:
Justin Pryzby <pryzby@telsasoft.com>
Дата:
On Sat, Mar 28, 2020 at 10:33:23AM -0300, Ranier Vilela wrote:
> Theses variables, are assigned with values that never is used and, can
> safely have their values removed.

I came across this one recently.

commit ccf85a5512fe7cfd76c6586b67fe06d911428d34
Author: Justin Pryzby 
Date:   Thu Apr 23 21:54:27 2020 -0500

    unused variable found@AttrDefaultFetch()..
    
    since:
    commit 16828d5c0273b4fe5f10f42588005f16b415b2d8
    Author: Andrew Dunstan 
    Date:   Wed Mar 28 10:43:52 2018 +1030
    
        Fast ALTER TABLE ADD COLUMN with a non-NULL default

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 9f1f11d0c1..f911d2802f 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4240,7 +4240,6 @@ AttrDefaultFetch(Relation relation)
 	HeapTuple	htup;
 	Datum		val;
 	bool		isnull;
-	int			found;
 	int			i;
 
 	ScanKeyInit(&skey,
@@ -4251,7 +4250,6 @@ AttrDefaultFetch(Relation relation)
 	adrel = table_open(AttrDefaultRelationId, AccessShareLock);
 	adscan = systable_beginscan(adrel, AttrDefaultIndexId, true,
 								NULL, 1, &skey);
-	found = 0;
 
 	while (HeapTupleIsValid(htup = systable_getnext(adscan)))
 	{
@@ -4266,8 +4264,6 @@ AttrDefaultFetch(Relation relation)
 				elog(WARNING, "multiple attrdef records found for attr %s of rel %s",
 					 NameStr(attr->attname),
 					 RelationGetRelationName(relation));
-			else
-				found++;
 
 			val = fastgetattr(htup,
 							  Anum_pg_attrdef_adbin,



FAQ