summaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorDavid Rowley2022-08-24 00:27:12 +0000
committerDavid Rowley2022-08-24 00:27:12 +0000
commit421892a192b8f95ab96c5edb61d424f80a4221d0 (patch)
tree74b077cee1c0c21fef0faec5ff0a63d050f991ca /src/backend/access
parent869e56a39976a42a393adc2d69df3abce7eff18f (diff)
Further reduce warnings with -Wshadow=compatible-local
In a similar effort to f01592f91, here we're targetting fixing the warnings that -Wshadow=compatible-local produces that we can fix by moving a variable to an inner scope to stop that variable from being shadowed by another variable declared somewhere later in the function. All of the warnings being fixed here are changing the scope of variables which are being used as an iterator for a "for" loop. In each instance, the fix happens to be changing the for loop to use the C99 type initialization. Much of this code likely pre-dates our use of C99. Reducing the scope of the outer scoped variable seems like the safest way to fix these. Renaming seems more likely to risk patches using the wrong variable. Reducing the scope is more likely to result in a compilation failure after applying some future patch rather than introducing bugs with it. By my count, this takes the warning count from 129 down to 114. Author: Justin Pryzby Discussion: https://postgr.es/m/CAApHDvrwLGBP%2BYw9vriayyf%3DXR4uPWP5jr6cQhP9au_kaDUhbA%40mail.gmail.com
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/brin/brin.c3
-rw-r--r--src/backend/access/brin/brin_minmax_multi.c3
-rw-r--r--src/backend/access/gist/gist.c3
3 files changed, 3 insertions, 6 deletions
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index e88f7efa7e4..69f21abfb59 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -372,7 +372,6 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
**nullkeys;
int *nkeys,
*nnullkeys;
- int keyno;
char *ptr;
Size len;
char *tmp PG_USED_FOR_ASSERTS_ONLY;
@@ -454,7 +453,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
memset(nnullkeys, 0, sizeof(int) * bdesc->bd_tupdesc->natts);
/* Preprocess the scan keys - split them into per-attribute arrays. */
- for (keyno = 0; keyno < scan->numberOfKeys; keyno++)
+ for (int keyno = 0; keyno < scan->numberOfKeys; keyno++)
{
ScanKey key = &scan->keyData[keyno];
AttrNumber keyattno = key->sk_attno;
diff --git a/src/backend/access/brin/brin_minmax_multi.c b/src/backend/access/brin/brin_minmax_multi.c
index 10d4f17bc6f..a581659fe2b 100644
--- a/src/backend/access/brin/brin_minmax_multi.c
+++ b/src/backend/access/brin/brin_minmax_multi.c
@@ -582,7 +582,6 @@ brin_range_serialize(Ranges *range)
int typlen;
bool typbyval;
- int i;
char *ptr;
/* simple sanity checks */
@@ -662,7 +661,7 @@ brin_range_serialize(Ranges *range)
*/
ptr = serialized->data; /* start of the serialized data */
- for (i = 0; i < nvalues; i++)
+ for (int i = 0; i < nvalues; i++)
{
if (typbyval) /* simple by-value data types */
{
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index 5866c6aaaf7..30069f139c7 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -234,7 +234,6 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
Page page = BufferGetPage(buffer);
bool is_leaf = (GistPageIsLeaf(page)) ? true : false;
XLogRecPtr recptr;
- int i;
bool is_split;
/*
@@ -420,7 +419,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
{
char *data = (char *) (ptr->list);
- for (i = 0; i < ptr->block.num; i++)
+ for (int i = 0; i < ptr->block.num; i++)
{
IndexTuple thistup = (IndexTuple) data;