Re: pgsql: Centralize definition of integer limits.

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Centralize definition of integer limits.
Date: 2015-03-30 05:27:20
Message-ID: CAB7nPqTsbK683aXYGHz+JjYU2zYuk2hrETHBhrUVR+hDQLn7hQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Mon, Mar 30, 2015 at 2:01 PM, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
wrote:

>
>
>
> On Thu, Mar 26, 2015 at 6:49 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> > Centralize definition of integer limits.
> >
> > Several submitted and even committed patches have run into the problem
> > that C89, our baseline, does not provide minimum/maximum values for
> > various integer datatypes. C99's stdint.h does, but we can't rely on
> > it.
> >
> > Several parts of the code defined limits locally, so instead centralize
> > the definitions to c.h.
> >
> > This patch also changes the more obvious usages of literal limit values;
> > there's more places that could be changed, but it's less clear whether
> > it's beneficial to change those.
>
> My OSX dev box is generating a couple of warnings since this commit:
> pg_dump.c:14548:45: warning: format specifies type 'long' but the argument
> has type 'long long' [-Wformat]
> snprintf(bufm, sizeof(bufm), INT64_FORMAT, SEQ_MINVALUE);
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
> ../../../src/include/pg_config_manual.h:52:22: note: expanded from macro
> 'SEQ_MINVALUE'
> #define SEQ_MINVALUE (-SEQ_MAXVALUE)
> ^
> /usr/include/secure/_stdio.h:56:62: note: expanded from macro 'snprintf'
> __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
> ^
> pg_dump.c:14549:45: warning: format specifies type 'long' but the argument
> has type 'long long' [-Wformat]
> snprintf(bufx, sizeof(bufx), INT64_FORMAT, SEQ_MAXVALUE);
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
> ../../../src/include/pg_config_manual.h:51:22: note: expanded from macro
> 'SEQ_MAXVALUE'
> #define SEQ_MAXVALUE INT64_MAX
> ^~~~~~~~~
> /usr/include/stdint.h:122:26: note: expanded from macro 'INT64_MAX'
> #define INT64_MAX 9223372036854775807LL
> ^~~~~~~~~~~~~~~~~~~~~
> /usr/include/secure/_stdio.h:56:62: note: expanded from macro 'snprintf'
> __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
>
> Thoughts?
>

INT64_MODIFIER is "l" on OSX, causing this warning. Perhaps there is
something better to do instead of casting blindly to int64. Thoughts?
--
Michael

Attachment Content-Type Size
20150330_pgdump_fix_int64_cast.patch application/x-patch 656 bytes

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2015-03-30 10:24:48 pgsql: Add index-only scan support to range type GiST opclass.
Previous Message Michael Paquier 2015-03-30 05:01:25 Re: pgsql: Centralize definition of integer limits.

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2015-03-30 05:28:37 Re: Combining Aggregates
Previous Message David Rowley 2015-03-30 05:08:19 Re: Combining Aggregates