Re: warn_unused_results

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: warn_unused_results
Date: 2020-10-17 15:58:26
Message-ID: 118217.1602950306@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)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.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2020-10-17 15:59:26 Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view?
Previous Message Alvaro Herrera 2020-10-17 15:54:29 Re: partition routing layering in nodeModifyTable.c