pgsql: Rationalize snprintf.c's handling of "ll" formats. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Rationalize snprintf.c's handling of "ll" formats.
Date
Msg-id E1g7lxW-00075l-Px@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Provide fast path in snprintf.c for conversion specs that areju
Next
From: Andres Freund
Date:
Subject: pgsql: Fix issues around EXPLAIN with JIT.