Re: silence compiler warning in brin.c

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Zhihong Yu <zyu(at)yugabyte(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: silence compiler warning in brin.c
Date: 2022-06-01 21:08:03
Message-ID: 710790.1654117683@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Nathan Bossart <nathandbossart(at)gmail(dot)com> writes:
> On Wed, Jun 01, 2022 at 01:06:21PM -0400, Tom Lane wrote:
>> It looks like
>> AtEOXact_GUC asserts nestLevel > 0, so that either 0 or -1 would
>> do as an "invalid" value; I'd lean a bit to using 0.

> I only chose -1 to follow a117ceb's example in amcheck. I have no
> preference.

Hmm, if we're following amcheck's example it should be more like this:

diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index 52f171772d..0de1441dc6 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -1051,7 +1051,13 @@ brin_summarize_range(PG_FUNCTION_ARGS)
save_nestlevel = NewGUCNestLevel();
}
else
+ {
heapRel = NULL;
+ /* Set these just to suppress "uninitialized variable" warnings */
+ save_userid = InvalidOid;
+ save_sec_context = -1;
+ save_nestlevel = -1;
+ }

indexRel = index_open(indexoid, ShareUpdateExclusiveLock);

I like this better anyway since the fact that the other two variables
aren't warned about seems like an implementation artifact.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2022-06-01 21:11:12 Re: pg_upgrade test writes to source directory
Previous Message Andres Freund 2022-06-01 21:05:28 Re: [RFC] building postgres with meson