From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: warn_unused_results
Date: Fri, 23 Oct 2020 10:14:12 +0200
Message-ID: <819ae3bf-ecb5-84c4-c30c-9990d0a7bfca@2ndquadrant.com> (raw)
In-Reply-To: <118217.1602950306@sss.pgh.pa.us>
References: <e3753562-99cd-b65f-5aca-687dfd1ec2fc@2ndquadrant.com>
<118217.1602950306@sss.pgh.pa.us>
On 2020-10-17 17:58, Tom Lane wrote:
> Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
>> Forgetting to assign the return value of list APIs such as lappend() is
>> a perennial favorite. The compiler can help point out such mistakes.
>> GCC has an attribute warn_unused_results. Also C++ has standardized
>> this under the name "nodiscard", and C has a proposal to do the same
>> [0]. In my patch I call the symbol pg_nodiscard, so that perhaps in a
>> distant future one only has to do s/pg_nodiscard/nodiscard/ or something
>> similar. Also, the name is short enough that it doesn't mess up the
>> formatting of function declarations too much.
>
> +1 in principle (I've not read the patch in detail); but I wonder what
> pgindent does with these added keywords.
pgindent doesn't seem to want to change anything about the patched files
as I had sent them.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: peter.eisentraut@2ndquadrant.com, tgl@sss.pgh.pa.us
Subject: Re: warn_unused_results
In-Reply-To: <819ae3bf-ecb5-84c4-c30c-9990d0a7bfca@2ndquadrant.com>
References: <e3753562-99cd-b65f-5aca-687dfd1ec2fc@2ndquadrant.com> <118217.1602950306@sss.pgh.pa.us> <819ae3bf-ecb5-84c4-c30c-9990d0a7bfca@2ndquadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox