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 <and...@tao11.riddles.org.uk> wrote in <87619q6ouh....@news-spur.riddles.org.uk> > >>>>> "Kevin" == Kevin Grittner <kgri...@ymail.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
diff --git a/contrib/pgcrypto/imath.h b/contrib/pgcrypto/imath.h index 0a4f0f7..7c30bd4 100644 --- a/contrib/pgcrypto/imath.h +++ b/contrib/pgcrypto/imath.h @@ -44,14 +44,14 @@ typedef int mp_result; typedef uint32 mp_digit; typedef uint64 mp_word; -#define MP_DIGIT_MAX 0xFFFFFFFFULL -#define MP_WORD_MAX 0xFFFFFFFFFFFFFFFFULL +#define MP_DIGIT_MAX UINT32_MAX +#define MP_WORD_MAX UINT64_MAX #else typedef uint16 mp_digit; typedef uint32 mp_word; -#define MP_DIGIT_MAX 0xFFFFUL -#define MP_WORD_MAX 0xFFFFFFFFUL +#define MP_DIGIT_MAX UINT16_MAX +#define MP_WORD_MAX UINT32_MAX #endif typedef struct mpz diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c index 0cc753e..6ff99e6 100644 --- a/src/backend/utils/mb/wchar.c +++ b/src/backend/utils/mb/wchar.c @@ -729,7 +729,7 @@ utf8_to_unicode(const unsigned char *c) (c[3] & 0x3f)); else /* that is an invalid code on purpose */ - return 0xffffffff; + return UINT32_MAX; } static int diff --git a/src/bin/psql/mbprint.c b/src/bin/psql/mbprint.c index e29c619..6b3f17d 100644 --- a/src/bin/psql/mbprint.c +++ b/src/bin/psql/mbprint.c @@ -67,7 +67,7 @@ utf8_to_unicode(const unsigned char *c) (c[3] & 0x3f)); else /* that is an invalid code on purpose */ - return 0xffffffff; + return UINT32_MAX; } diff --git a/src/interfaces/ecpg/pgtypeslib/dt.h b/src/interfaces/ecpg/pgtypeslib/dt.h index 145e2b7..028f0df 100644 --- a/src/interfaces/ecpg/pgtypeslib/dt.h +++ b/src/interfaces/ecpg/pgtypeslib/dt.h @@ -320,8 +320,8 @@ do { \ #ifdef HAVE_INT64_TIMESTAMP -#define DT_NOBEGIN (-INT64CONST(0x7fffffffffffffff) - 1) -#define DT_NOEND (INT64CONST(0x7fffffffffffffff)) +#define DT_NOBEGIN INT64_MIN +#define DT_NOEND INT64_MAX #else #ifdef HUGE_VAL
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers