pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: warn_unused_results
Date: Mon, 9 Nov 2020 08:23:31 +0100
Message-ID: <8ef6a7dc-5ea1-46b3-4406-7be7d07886f0@2ndquadrant.com> (raw)
In-Reply-To: <20201109065606.GA11424@paquier.xyz>
References: <e3753562-99cd-b65f-5aca-687dfd1ec2fc@2ndquadrant.com>
	<20201109065606.GA11424@paquier.xyz>

On 2020-11-09 07:56, Michael Paquier wrote:
> This is accepted by clang, and MSVC has visibly an equivalent for
> that, as of VS 2012:
> #elif defined(_MSC_VER) && (_MSC_VER >= 1700)
> #define pg_nodiscard _Check_return_
> We don't care about the 1700 condition as we support only >= 1800 on
> HEAD, and in this case the addition of pg_nodiscard would be required
> on the definition and the declaration.  Should it be added?  It is
> much more invasive than the gcc/clang equivalent though..

AFAICT from the documentation, this only applies for special "analyze" 
runs, not as a normal compiler warning.  Do we have any support for 
analyze runs with MSVC?

> FWIW, I saw an extra case with parsePGArray() today.

AFAICT, that's more in the category of checking for error returns, which 
is similar to the "fortify" options that some environments have for 
checking the return of fwrite() etc.

> I am not sure
> about the addition of repalloc(), as it is quite obvious that one has
> to use its result.  Lists are fine, these are proper to PG internals
> and beginners tend to be easily confused in the way to use them.

realloc() is listed in the GCC documentation as the reason this option 
exists, and glibc tags its realloc() with this attribute, so doing the 
same for repalloc() seems sensible.

-- 
Peter Eisentraut
2ndQuadrant, an EDB company
https://www.2ndquadrant.com/





view thread (7+ messages)  latest in thread

Message-ID: <8ef6a7dc-5ea1-46b3-4406-7be7d07886f0@2ndquadrant.com>
Permalink:  ../8ef6a7dc-5ea1-46b3-4406-7be7d07886f0@2ndquadrant.com/
Also on:    postgresql.org/message-id/8ef6a7dc-5ea1-46b3-4406-7be7d07886f0@2ndquadrant.com

 · 

reply

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, michael@paquier.xyz
  Subject: Re: warn_unused_results
  In-Reply-To: <8ef6a7dc-5ea1-46b3-4406-7be7d07886f0@2ndquadrant.com>
  References: <e3753562-99cd-b65f-5aca-687dfd1ec2fc@2ndquadrant.com> <20201109065606.GA11424@paquier.xyz> <8ef6a7dc-5ea1-46b3-4406-7be7d07886f0@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