pg_xlogdump compiler warning

Started by Peter Eisentrautalmost 13 years ago4 messages
#1Peter Eisentraut
peter_e@gmx.net

compat.c: In function ‘timestamptz_to_str’:
compat.c:56:9: error: passing argument 1 of ‘localtime’ from incompatible pointer type [-Werror]
In file included from compat.c:21:0:
/usr/include/time.h:237:19: note: expected ‘const time_t *’ but argument is of type ‘pg_time_t *’

gcc 4.7.2

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Andres Freund
andres@2ndquadrant.com
In reply to: Peter Eisentraut (#1)
1 attachment(s)
Re: pg_xlogdump compiler warning

Hi,

On 2013-02-25 18:15:48 -0500, Peter Eisentraut wrote:

compat.c: In function ‘timestamptz_to_str’:
compat.c:56:9: error: passing argument 1 of ‘localtime’ from incompatible pointer type [-Werror]
In file included from compat.c:21:0:
/usr/include/time.h:237:19: note: expected ‘const time_t *’ but argument is of type ‘pg_time_t *’

gcc 4.7.2

32bit I guess?

A simple cast should do for now. Patch attached.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachments:

correct-cast-to-time_t.patchtext/x-patch; charset=us-asciiDownload
diff --git a/contrib/pg_xlogdump/compat.c b/contrib/pg_xlogdump/compat.c
index 99ecad7..0aee756 100644
--- a/contrib/pg_xlogdump/compat.c
+++ b/contrib/pg_xlogdump/compat.c
@@ -52,7 +52,8 @@ timestamptz_to_str(TimestampTz dt)
 	static char buf[MAXDATELEN + 1];
 	static char ts[MAXDATELEN + 1];
 	static char zone[MAXDATELEN + 1];
-	pg_time_t	result = timestamptz_to_time_t(dt);
+	/* cast to time_t so we can use localtime() */
+	time_t	result = (time_t)timestamptz_to_time_t(dt);
 	struct tm  *ltime = localtime(&result);
 
 	strftime(ts, sizeof(zone), "%Y-%m-%d %H:%M:%S", ltime);
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andres Freund (#2)
Re: pg_xlogdump compiler warning

Andres Freund <andres@2ndquadrant.com> writes:

On 2013-02-25 18:15:48 -0500, Peter Eisentraut wrote:

compat.c: In function ‘timestamptz_to_str’:
compat.c:56:9: error: passing argument 1 of ‘localtime’ from incompatible pointer type [-Werror]
In file included from compat.c:21:0:
/usr/include/time.h:237:19: note: expected ‘const time_t *’ but argument is of type ‘pg_time_t *’

32bit I guess?

Yeah, I see the same on a 32-bit machine.

A simple cast should do for now. Patch attached.

Pushed along with some other, more cosmetic cleanups.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Andres Freund
andres@2ndquadrant.com
In reply to: Tom Lane (#3)
Re: pg_xlogdump compiler warning

On 2013-02-26 15:52:01 -0500, Tom Lane wrote:

Andres Freund <andres@2ndquadrant.com> writes:

On 2013-02-25 18:15:48 -0500, Peter Eisentraut wrote:

compat.c: In function ‘timestamptz_to_str’:
compat.c:56:9: error: passing argument 1 of ‘localtime’ from incompatible pointer type [-Werror]
In file included from compat.c:21:0:
/usr/include/time.h:237:19: note: expected ‘const time_t *’ but argument is of type ‘pg_time_t *’

32bit I guess?

Yeah, I see the same on a 32-bit machine.

A simple cast should do for now. Patch attached.

Pushed along with some other, more cosmetic cleanups.

Thanks. The statics's et al were stupid, my fault.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers