pgsql: Silence some Coverity warnings and improve code consistency.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Silence some Coverity warnings and improve code consistency.
Date: 2021-04-11 21:02:13
Message-ID: E1lVhDh-0000go-Kr@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Silence some Coverity warnings and improve code consistency.

Coverity complained about possible overflow in expressions like
intresult = tm->tm_sec * 1000000 + fsec;
on the grounds that the multiplication would happen in 32-bit
arithmetic before widening to the int64 result. I think these
are all false positives because of the limited possible range of
tm_sec; but nonetheless it seems silly to spell it like that when
nearby lines have the identical computation written with a 64-bit
constant.

... or more accurately, with an LL constant, which is not project
style. Make all of these use INT64CONST(), as we do elsewhere.

This is all new code from a2da77cdb, so no need for back-patch.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6277435a8a89c59f716c111200c072d1454b8ff2

Modified Files
--------------
src/backend/utils/adt/date.c | 14 +++++++-------
src/backend/utils/adt/timestamp.c | 26 +++++++++++++-------------
2 files changed, 20 insertions(+), 20 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message tsunakawa.takay@fujitsu.com 2021-04-12 01:40:36 RE: pgsql: Add a new GUC and a reloption to enable inserts in parallel-mode
Previous Message Tom Lane 2021-04-11 17:23:01 pgsql: Add macro PGWARNING, and make PGERROR available on all platforms