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

From Ranier Vilela
Subject Re: Out-of-memory error reports in libpq
Date
Msg-id CAEudQAqZ0-j8AxjA8Kc0pw2UuxViBogAjjLZkzkY21w-UEQ-kQ@mail.gmail.com
Whole thread Raw
In response to Re: Out-of-memory error reports in libpq  (Peter Smith <smithpb2250@gmail.com>)
List pgsql-hackers
Em qui., 29 de jul. de 2021 às 04:02, Peter Smith <smithpb2250@gmail.com> escreveu:
(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");
The C compiler will expand:

res->errMsg = msg ? msg : libpq_gettext("out of memory\n");

to 

if (msg)
     res->errMsg = msg;
else
     res->errMsg = libpq_gettext("out of memory\n");

What IMHO is much more readable.

regards,
Ranier Vilela

pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: Re: Out-of-memory error reports in libpq
Next
From: Amul Sul
Date:
Subject: Re: [Patch] ALTER SYSTEM READ ONLY