Re: Out-of-memory error reports in libpq - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: Out-of-memory error reports in libpq
Date
Msg-id d8567866-dd01-41df-cba1-b5a372b6d90e@dunslane.net
Whole thread Raw
In response to Re: Out-of-memory error reports in libpq  (Peter Smith <smithpb2250@gmail.com>)
Responses Re: Out-of-memory error reports in libpq
List pgsql-hackers
On 7/29/21 3:01 AM, Peter Smith wrote:
> (This is not a code review - this is just to satisfy my curiosity)
>
> I've seen lots of code like this where I may have been tempted to use
> a ternary operator for readability, so I was wondering is there a PG
> convention to avoid such ternary operator assignments, or is it simply
> a personal taste thing, or is there some other reason?
>
> For example:
>
> if (msg)
>   res->errMsg = msg;
> else
>   res->errMsg = libpq_gettext("out of memory\n");
>
> VERSUS:
>
> res->errMsg = msg ? msg : libpq_gettext("out of memory\n");
>


A simple grep on the sources should disabuse you of any idea that there
is such a convention. The code is littered with examples of the ?: operator.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com




pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Doc: Fixed the result of the bit_count example
Next
From: Andrew Dunstan
Date:
Subject: Re: Replace l337sp34k in comments.