Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nwVZd-0005uS-RQ for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Jun 2022 21:08:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nwVZc-00075L-N7 for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Jun 2022 21:08:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nwVZc-00075B-DF for pgsql-hackers@lists.postgresql.org; Wed, 01 Jun 2022 21:08:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nwVZW-0008Qz-2h for pgsql-hackers@postgresql.org; Wed, 01 Jun 2022 21:08:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 251L83Jd710791; Wed, 1 Jun 2022 17:08:03 -0400 From: Tom Lane To: Nathan Bossart cc: Zhihong Yu , PostgreSQL-development Subject: Re: silence compiler warning in brin.c In-reply-to: <20220601173824.GA2396891@nathanxps13> References: <20220601163537.GA2331988@nathanxps13> <626379.1654103181@sss.pgh.pa.us> <20220601173824.GA2396891@nathanxps13> Comments: In-reply-to Nathan Bossart message dated "Wed, 01 Jun 2022 10:38:24 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <710789.1654117683.1@sss.pgh.pa.us> Date: Wed, 01 Jun 2022 17:08:03 -0400 Message-ID: <710790.1654117683@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart 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