Re: Silencing the remaining clang 15 warnings - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Silencing the remaining clang 15 warnings
Date
Msg-id 542990.1663628813@sss.pgh.pa.us
Whole thread Raw
In response to Re: Silencing the remaining clang 15 warnings  (Thomas Munro <thomas.munro@gmail.com>)
Responses Re: Silencing the remaining clang 15 warnings
List pgsql-hackers
Thomas Munro <thomas.munro@gmail.com> writes:
> On Tue, Sep 20, 2022 at 7:20 AM Tom Lane <tgl@sss.pgh.pa.us> 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



pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Silencing the remaining clang 15 warnings
Next
From: Michel Pelletier
Date:
Subject: Proposal to use JSON for Postgres Parser format