Skip to content

Commit dadce65

Browse files
committed
Don't assume that struct timeval's tv_sec field is the same datatype as
time_t; on some platforms they are not the same width. Per Manfred Koizar.
1 parent 1899203 commit dadce65

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/backend/utils/adt/nabstime.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.119 2004/03/22 15:34:22 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.120 2004/05/05 17:28:46 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -191,9 +191,9 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
191191
time -= CTimeZone;
192192

193193
if ((!HasCTZSet) && (tzp != NULL))
194-
tx = localtime((time_t *) &time);
194+
tx = localtime(&time);
195195
else
196-
tx = gmtime((time_t *) &time);
196+
tx = gmtime(&time);
197197

198198
tm->tm_year = tx->tm_year + 1900;
199199
tm->tm_mon = tx->tm_mon + 1;
@@ -1728,10 +1728,12 @@ timeofday(PG_FUNCTION_ARGS)
17281728
char buf[128];
17291729
text *result;
17301730
int len;
1731+
time_t tt;
17311732

17321733
gettimeofday(&tp, &tpz);
1734+
tt = (time_t) tp.tv_sec;
17331735
strftime(templ, sizeof(templ), "%a %b %d %H:%M:%S.%%06d %Y %Z",
1734-
localtime((time_t *) &tp.tv_sec));
1736+
localtime(&tt));
17351737
snprintf(buf, sizeof(buf), templ, tp.tv_usec);
17361738

17371739
len = VARHDRSZ + strlen(buf);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy