From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Remove unnecessary uses of Abs()
Date: Fri, 07 Oct 2022 10:38:16 -0400
Message-ID: <3155926.1665153496@sss.pgh.pa.us> (raw)
In-Reply-To: <E1oglg5-001J3Z-7n@gemulon.postgresql.org>
References: <E1oglg5-001J3Z-7n@gemulon.postgresql.org>
Peter Eisentraut <peter@eisentraut.org> writes:
> Remove unnecessary uses of Abs()
Re-reading this, I noticed something that's probably not good:
in ecpg/pgtypeslib/interval.c you did
- sprintf(cp, "%02d.%0*d", abs(sec), precision, (int) Abs(fsec));
+ sprintf(cp, "%02d.%0*d", abs(sec), precision, abs(fsec));
(in 2 places). I think this has possibly broken the direction of rounding
for negative values, because we'll now truncate to integer before changing
sign. Maybe it's okay but you have to make assumptions about what it'll
do. Safer would have been
+ sprintf(cp, "%02d.%0*d", abs(sec), precision, (int) fabs(fsec));
There is similar-looking coding in remove_gene(), but I didn't check
the data type involved.
regards, tom lane
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, peter@eisentraut.org
Subject: Re: pgsql: Remove unnecessary uses of Abs()
In-Reply-To: <3155926.1665153496@sss.pgh.pa.us>
References: <E1oglg5-001J3Z-7n@gemulon.postgresql.org> <3155926.1665153496@sss.pgh.pa.us>
* 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