pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Rationalize snprintf.c's handling of "ll" formats.
Date: Wed, 03 Oct 2018 18:33:18 +0000
Message-ID: <E1g7lxW-00075l-Px@gemulon.postgresql.org> (raw)

Rationalize snprintf.c's handling of "ll" formats.

Although all known platforms define "long long" as 64 bits, it still feels
a bit shaky to be using "va_arg(args, int64)" to pull out an argument that
the caller thought was declared "long long".  The reason it was coded like
this, way back in commit 3311c7669, was to work around the possibility that
the compiler had no type named "long long" --- and, at the time, that it
maybe didn't have 64-bit ints at all.  Now that we're requiring compilers
to support C99, those concerns are moot.  Let's make the code clearer and
more bulletproof by writing "long long" where we mean "long long".

This does introduce a hazard that we'd inefficiently use 128-bit arithmetic
to convert plain old integers.  The way to tackle that would be to provide
two versions of fmtint(), one for "long long" and one for narrower types.
Since, as of today, no platforms require that, we won't bother with the
extra code for now.

Discussion: https://postgr.es/m/1680.1538587115@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/595a0eab7f425e3484639fae1f7e221fe9c2651a

Modified Files
--------------
src/port/snprintf.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)



Message-ID: <E1g7lxW-00075l-Px@gemulon.postgresql.org>
Permalink:  ../E1g7lxW-00075l-Px@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1g7lxW-00075l-Px@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: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Rationalize snprintf.c's handling of "ll" formats.
  In-Reply-To: <E1g7lxW-00075l-Px@gemulon.postgresql.org>
  References: <E1g7lxW-00075l-Px@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