Re: INT64_MIN and _MAX

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Petr Jelinek <petr(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: INT64_MIN and _MAX
Date: 2015-03-22 17:20:22
Message-ID: 87619tc5wc.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "Andres" == Andres Freund <andres(at)anarazel(dot)de> writes:

>> Hm, it looks like the same could be said for INT32_MIN and _MAX;
>> some places use INT_MIN etc., others say "we shouldn't assume int =
>> int32" and use (-0x7fffffff - 1) or whatever instead.

Andres> I have been annoyed by this multiple times. I think we should
Andres> make sure the C99 defines are there (providing values if they
Andres> aren't) and always use those. We've used them in parts of the
Andres> tree long enough that it's unlikely to cause problems. Nothing
Andres> is helped by using different things in other parts of the tree.

Andres> Willing to cook up a patch?

How's this one?

This replaces the one I posted before; it does both INT64_MIN/MAX and
INT32_MIN/MAX, and also int16/int8/uint*. Uses of 0x7fffffff in code
have been replaced unless there was a reason not to, with either INT_MAX
or INT32_MAX according to the type required.

What I have _not_ done yet is audit uses of INT_MIN/MAX to see which
ones should really be INT32_MIN/MAX.

--
Andrew (irc:RhodiumToad)

Attachment Content-Type Size
int_minmax.patch text/x-patch 10.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Weimer 2015-03-22 17:34:11 Re: Remove fsync ON/OFF as a visible option?
Previous Message Воронин Дмитрий 2015-03-22 16:48:01 Re: New functions