pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Clean up some questionable usages of DatumGet* macros
Date: Fri, 04 Jun 2021 10:42:46 +0000
Message-ID: <E1lp7Hq-0007bX-W3@gemulon.postgresql.org> (raw)

Clean up some questionable usages of DatumGet* macros

This tidies up some questionable coding which made use of
DatumGetPointer() for Datums being passed into functions where the
parameter is expected to be a cstring.  We saw no compiler warnings with
the old code as the Pointer type used in DatumGetPointer() happens to
be a char * rather than a void *.  However, that's no excuse and we should
be using the correct macro for the job.

Here we also make use of OutputFunctionCall() rather than using
FunctionCall1() directly to call the type's output function.
OutputFunctionCall() is the standard way to do this.  It casts the
returned value to a cstring for us.

In passing get rid of a duplicate call to strlen().  Most compilers will
likely optimize away the 2nd call, but there may be some that won't.  In
any case, this just aligns the code to some other nearby code that already
does this.

Discussion: https://postgr.es/m/CAApHDvq1D=ehZ8hey8Hz67N+_Zth0GHO5wiVCfv1YcGPMXJq0A@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8bdb36aab287f564eac534878bc0e1d873a4e3db

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)



Message-ID: <E1lp7Hq-0007bX-W3@gemulon.postgresql.org>
Permalink:  ../E1lp7Hq-0007bX-W3@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lp7Hq-0007bX-W3@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: drowley@postgresql.org
  Subject: Re: pgsql: Clean up some questionable usages of DatumGet* macros
  In-Reply-To: <E1lp7Hq-0007bX-W3@gemulon.postgresql.org>
  References: <E1lp7Hq-0007bX-W3@gemulon.postgresql.org>

* 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