Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YcRpK-0007vU-Hp for pgsql-committers@arkaria.postgresql.org; Mon, 30 Mar 2015 05:01:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YcRpJ-0008VA-Vd for pgsql-committers@arkaria.postgresql.org; Mon, 30 Mar 2015 05:01:30 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YcRpJ-0008V4-6w for pgsql-committers@postgresql.org; Mon, 30 Mar 2015 05:01:29 +0000 Received: from mail-qg0-x234.google.com ([2607:f8b0:400d:c04::234]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YcRpG-0004dh-9N for pgsql-committers@postgresql.org; Mon, 30 Mar 2015 05:01:27 +0000 Received: by qgf60 with SMTP id 60so160167302qgf.3 for ; Sun, 29 Mar 2015 22:01:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=FKPXePMzq9ogozp2NMVrWgxSjgGfLrZvj87RS1h9fuM=; b=L4CzlVoCzQ3I1PDxHwNtzqkPdn5vltvB6eMZLp/Dg9a1T8Kt+x5gFF2rSpibxCmV32 e1P20J3GKZs6WsPysn9HF15//isVtGm8zQxPE8B0kxLGPxbj8eLMLa25lnT21xNehZIr ZsgtqAJGoOc6erBnSpppcGrRTp8hEKz2j6seO6POCAsOinrerE2BlpGzdHzDTEDYKrkC E9CqQK7cSV4+JO+btwnEzQ6XBrOCE6E5CqtXd8SfAwI6/x+5/PIEwEX23HI7s0Mcyoac GoCB6MRKODdFEKrgxNIdV6tKDKanmqaazD0nk0rkGDd4E1U2NzNjZVVo2XjE+lRrmfeN lT1A== MIME-Version: 1.0 X-Received: by 10.140.41.113 with SMTP id y104mr37190930qgy.25.1427691685383; Sun, 29 Mar 2015 22:01:25 -0700 (PDT) Received: by 10.140.86.18 with HTTP; Sun, 29 Mar 2015 22:01:25 -0700 (PDT) In-Reply-To: References: Date: Mon, 30 Mar 2015 14:01:25 +0900 Message-ID: Subject: Re: pgsql: Centralize definition of integer limits. From: Michael Paquier To: Andres Freund Cc: pgsql-committers@postgresql.org Content-Type: multipart/alternative; boundary=001a11c121b0c1937205127a5fb0 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org --001a11c121b0c1937205127a5fb0 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Mar 26, 2015 at 6:49 AM, Andres Freund 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? -- Michael --001a11c121b0c1937205127a5fb0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On Thu, Mar 26, 2015 at 6:49 AM, Andres Freun= d <andres@anarazel.de> wrot= e:
> Centralize definition of integer limits.
>
> Several= submitted and even committed patches have run into the problem
> tha= t C89, our baseline, does not provide minimum/maximum values for
> va= rious integer datatypes. C99's stdint.h does, but we can't rely on<= br>> it.
>
> Several parts of the code defined limits locall= y, so instead centralize
> the definitions to c.h.
>
> Th= is patch also changes the more obvious usages of literal limit values;
&= gt; 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 &= #39;long long' [-Wformat]
=A0 =A0 =A0 =A0 snprintf(bufm, sizeof(bufm= ), INT64_FORMAT, SEQ_MINVALUE);
=A0 =A0 =A0 =A0 ~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
../../../src/include/pg_config_manual.h= :52:22: note: expanded from macro 'SEQ_MINVALUE'
#define SEQ_MIN= VALUE =A0 =A0(-SEQ_MAXVALUE)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 ^
/usr/include/secure/_stdio.h:56:62: note: expanded from macro = 9;snprintf'
=A0 __builtin___snprintf_chk (str, len, 0, __darwin_obsz= (str), __VA_ARGS__)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0^pg_dump.c:14549:45: warning: format specifies type 'long' but the = argument has type 'long long' [-Wformat]
=A0 =A0 =A0 =A0 snprint= f(bufx, sizeof(bufx), INT64_FORMAT, SEQ_MAXVALUE);
=A0 =A0 =A0 =A0 ~~~~~= ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
../../../src/include/= pg_config_manual.h:51:22: note: expanded from macro 'SEQ_MAXVALUE'<= br>#define SEQ_MAXVALUE =A0 =A0INT64_MAX
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 ^~~~~~~~~
/usr/include/stdint.h:122:26: note: expanded = from macro 'INT64_MAX'
#define INT64_MAX =A0 =A0 =A0 =A092233720= 36854775807LL
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0^~~~~~~= ~~~~~~~~~~~~~~
/usr/include/secure/_stdio.h:56:62: note: expanded from m= acro 'snprintf'
=A0 __builtin___snprintf_chk (str, len, 0, __dar= win_obsz(str), __VA_ARGS__)

Thoughts?
--
Michael
--001a11c121b0c1937205127a5fb0--