pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: warn_unused_results
Date: Tue, 10 Nov 2020 12:34:45 +0900
Message-ID: <20201110033445.GH1887@paquier.xyz> (raw)
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>

On Mon, Nov 09, 2020 at 08:23:31AM +0100, Peter Eisentraut wrote:
> 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?

You can run them by passing down /p:RunCodeAnalysis=true to MSBFLAGS
when calling the build script.  There are more options like
/p:CodeAnalysisRuleSet to define a set of rules.  By default the
output is rather noisy though now that I look at it.  And having to
add the flag to the definition and the declaration is annoying, so
what you are doing would be enough without MSVC.

>> 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.

Good point.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (7+ messages)  latest in thread

Message-ID: <20201110033445.GH1887@paquier.xyz>
Permalink:  ../20201110033445.GH1887@paquier.xyz/
Also on:    postgresql.org/message-id/20201110033445.GH1887@paquier.xyz

 · 

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

* 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