On Wed, Apr 29, 2015 at 10:11:02AM -0400, Stephen Frost wrote:
> Bruce,
>
> * Bruce Momjian ([email protected]) wrote:
> > to_char(): have format 'OF' only show the leading negative sign
> >
> > Previously both hours and minutes displayed as negative.
> >
> > Report by David Pozsar
>
> This is causing the following error for me:
>
> /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c: In
> function ‘DCH_to_char’:
> /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c:2510:6:
> warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has
> type ‘int’ [-Wformat=]
> sprintf(s, ":%02ld", abs(tm->tm_gmtoff % SECS_PER_HOUR) /
> SECS_PER_MINUTE);
> ^
>
> Since abs() is declared to return just an int. I don't see it anywhere
> in our tree and I'm not sure how portable it actually is, but labs() is
> supposedly in C89, so perhaps that should be used here instead?
OK, I have switched to labs() and will keep an eye on the buildfarm;
patch attached. (There is already an uncomfortable amount of red
there.)
--
Bruce Momjian <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
new file mode 100644
index 576db95..dbff94d
*** a/src/backend/utils/adt/formatting.c
--- b/src/backend/utils/adt/formatting.c
*************** DCH_to_char(FormatNode *node, bool is_in
*** 2507,2513 ****
s += strlen(s);
if (tm->tm_gmtoff % SECS_PER_HOUR != 0)
{
! sprintf(s, ":%02ld", abs(tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
s += strlen(s);
}
break;
--- 2507,2513 ----
s += strlen(s);
if (tm->tm_gmtoff % SECS_PER_HOUR != 0)
{
! sprintf(s, ":%02ld", labs(tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
s += strlen(s);
}
break;
--
Sent via pgsql-committers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers