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 1oaPqt-0005aa-BS for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Sep 2022 23:06:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oaPqr-0007tW-MG for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Sep 2022 23:06:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaPqr-0007tM-Ch for pgsql-hackers@lists.postgresql.org; Mon, 19 Sep 2022 23:06:57 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaPqo-0000LN-V3 for pgsql-hackers@lists.postgresql.org; Mon, 19 Sep 2022 23:06:56 +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 28JN6rVM542991; Mon, 19 Sep 2022 19:06:53 -0400 From: Tom Lane To: Thomas Munro cc: PostgreSQL Hackers Subject: Re: Silencing the remaining clang 15 warnings In-reply-to: References: <514615.1663615243@sss.pgh.pa.us> Comments: In-reply-to Thomas Munro message dated "Tue, 20 Sep 2022 10:56:16 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <542989.1663628813.1@sss.pgh.pa.us> Date: Mon, 19 Sep 2022 19:06:53 -0400 Message-ID: <542990.1663628813@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thomas Munro writes: > On Tue, Sep 20, 2022 at 7:20 AM Tom Lane wrote: >> * xlog.c's AdvanceXLInsertBuffer has a local variable "npages" >> that is only read in the "#ifdef WAL_DEBUG" stanza at the >> bottom. Here I've done the rather ugly and brute-force thing >> of wrapping all the variable's references in "#ifdef WAL_DEBUG". >> (I tried marking it PG_USED_FOR_ASSERTS_ONLY, but oddly that >> did not silence the warning.) I kind of wonder how useful this >> function's WAL_DEBUG output is --- maybe just dropping that >> altogether would be better? > No opinion on the value of the message, but maybe > pg_attribute_unused() would be better? I realized that the reason PG_USED_FOR_ASSERTS_ONLY didn't help is that it expands to empty in an assert-enabled build, which is what I was testing. So yeah, using pg_attribute_unused() directly would probably work better. (Also, I tried an assert-disabled build and found one additional new warning; same deal where clang doesn't believe "foo++;" is reason to consider foo to be used. That one, PG_USED_FOR_ASSERTS_ONLY can fix.) regards, tom lane