Re: INT64_MIN and _MAX

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: andrew(at)tao11(dot)riddles(dot)org(dot)uk
Cc: kgrittn(at)ymail(dot)com, andres(at)anarazel(dot)de, petr(at)2ndquadrant(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: INT64_MIN and _MAX
Date: 2015-03-25 01:39:39
Message-ID: 20150325.103939.119300819.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

Grep showed me some unfixed usages of bare constant or INT64CONST
as (u)int64 max/min values.

At Tue, 24 Mar 2015 21:57:42 +0000, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> wrote in <87619q6ouh(dot)fsf(at)news-spur(dot)riddles(dot)org(dot)uk>
> >>>>> "Kevin" == Kevin Grittner <kgrittn(at)ymail(dot)com> writes:
> Kevin> Well, InvalidSerCommitSeqNo was initially defined to be
> Kevin> UINT64_MAX -- but some buildfarm members didn't know about that
> Kevin> so it was changed to UINT64CONST(0xFFFFFFFFFFFFFFFF). It is
> Kevin> very much about wanting the maximum value for uint64.
>
> That one _is_ changed to UINT64_MAX in my patch.

./src/interfaces/ecpg/pgtypeslib/dt.h:
> #define DT_NOBEGIN (-INT64CONST(0x7fffffffffffffff) - 1)
> #define DT_NOEND (INT64CONST(0x7fffffffffffffff))

./contrib/pgcrypto/imath.h:
> #define MP_WORD_MAX 0xFFFFFFFFFFFFFFFFULL

Likewise, bare (u)int32/16 min/max's are found as following.

./contrib/pgcrypto/imath.h:
> #define MP_DIGIT_MAX 0xFFFFFFFFULL
..
> #define MP_DIGIT_MAX 0xFFFFUL
> #define MP_WORD_MAX 0xFFFFFFFFUL

# MP_DIGIT_MAX was wrong in word length. They are in the half
# length of MP_WORD_MAX.

./src/backend/utils/mb/wchar.c
./src/bin/psql/mbprint.c:
> return 0xffffffff;

Additional fixes for the above are in the patch attached.

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
int_minmax_add1.patch text/x-patch 1.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sawada Masahiko 2015-03-25 01:46:45 Re: Auditing extension for PostgreSQL (Take 2)
Previous Message Bruce Momjian 2015-03-25 01:11:00 Re: proposal: doc: simplify examples of dynamic SQL