mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-03-01 19:45:33 +08:00
Second try at fixing warnings caused by commit 9b43d73b3f
.
Commit ef3f9e642d
suppressed one cause of warnings here, but
recent clang on OS X is still unhappy because we're passing a "long"
to abs(). The fact that tm_gmtoff is declared as long is no doubt a
hangover from days when int might be only 16 bits; but Postgres has
never been able to run on such machines, so we can just cast it to int
with no worries. For consistency, also cast to int in the other
uses of tm_gmtoff in this stanza.
Note: this code is still broken on machines that don't follow C99
integer-division-truncates-towards-zero rules. Given the lack of
complaints about it, I don't feel a large desire to complicate things
enough to cope with the pre-C99 rules.
This commit is contained in:
parent
a4820434c1
commit
c90b85e4d9
@ -2503,11 +2503,11 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
||||
break;
|
||||
case DCH_OF:
|
||||
INVALID_FOR_INTERVAL;
|
||||
sprintf(s, "%+0*ld", S_FM(n->suffix) ? 0 : 3, tm->tm_gmtoff / SECS_PER_HOUR);
|
||||
sprintf(s, "%+0*d", S_FM(n->suffix) ? 0 : 3, (int) tm->tm_gmtoff / SECS_PER_HOUR);
|
||||
s += strlen(s);
|
||||
if (tm->tm_gmtoff % SECS_PER_HOUR != 0)
|
||||
if ((int) tm->tm_gmtoff % SECS_PER_HOUR != 0)
|
||||
{
|
||||
sprintf(s, ":%02d", abs(tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
|
||||
sprintf(s, ":%02d", abs((int) tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
|
||||
s += strlen(s);
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user