Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign - Mailing list pgsql-committers

From Bruce Momjian
Subject Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign
Date
Msg-id 20150429210524.GP31727@momjian.us
Whole thread Raw
In response to Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign  (Stephen Frost <sfrost@snowman.net>)
Responses Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-committers
On Wed, Apr 29, 2015 at 02:22:22PM -0400, Stephen Frost wrote:
> * Robert Haas (robertmhaas@gmail.com) wrote:
> > On Wed, Apr 29, 2015 at 10:11 AM, Stephen Frost <sfrost@snowman.net> wrote:
> > > * Bruce Momjian (bruce@momjian.us) 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
argumentof 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?
> >
> > I just removed the "l" for now, since %02d is used to print the result
> > of abs() elsewhere.  If that isn't right, someone can re-fix my fix.
>
> Works for me.  I'm no longer seeing the warning.

Oh, I see now that my commit generated a conflict and didn't apply.
Should we try labs() or just ignore it?

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +


pgsql-committers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign
Next
From: Robert Haas
Date:
Subject: pgsql: Add markup, for consistency.