[PATCH] 64-bit fix for date.c.

Subsystems: the rest

STALE3760d

7 messages, 4 authors, 2016-06-15 · open the first message on its own page

[PATCH] 64-bit fix for date.c.

From: Bernd Ahlers <hidden>
Date: 2016-06-15 22:46:34

Hello!

This unbreaks the localtime_r call on OpenBSD/sparc64 and removes
the following compiler warning.

"passing arg 1 of `localtime_r' from incompatible pointer type"
---
 date.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/date.c b/date.c
index 1165d30..409a17d 100644
--- a/date.c
+++ b/date.c
@@ -871,13 +871,15 @@ unsigned long approxidate(const char *date)
 	int number = 0;
 	struct tm tm, now;
 	struct timeval tv;
+	time_t time_sec;
 	char buffer[50];
 
 	if (parse_date(date, buffer, sizeof(buffer)) > 0)
 		return strtoul(buffer, NULL, 10);
 
 	gettimeofday(&tv, NULL);
-	localtime_r(&tv.tv_sec, &tm);
+	time_sec = tv.tv_sec;
+	localtime_r(&time_sec, &tm);
 	now = tm;
 	for (;;) {
 		unsigned char c = *date;
-- 
1.6.2.2

Re: [PATCH] 64-bit fix for date.c.

From: Jeff King <hidden>
Date: 2016-06-15 22:46:34

On Mon, Apr 06, 2009 at 07:26:37PM +0200, Bernd Ahlers wrote:
quoted hunk
@@ -871,13 +871,15 @@ unsigned long approxidate(const char *date)
 	struct timeval tv;
+	time_t time_sec;
[...]
 	gettimeofday(&tv, NULL);
-	localtime_r(&tv.tv_sec, &tm);
+	time_sec = tv.tv_sec;
+	localtime_r(&time_sec, &tm);
Hmph. According to POSIX, tv_sec _is_ a time_t. But I see on FreeBSD,
also, it is actually a "long". So I think this fix makes sense.

-Peff

Re: [PATCH] 64-bit fix for date.c.

From: Bernd Ahlers <hidden>
Date: 2016-06-15 22:46:42

Jeff King [Mon, Apr 06, 2009 at 03:06:58PM -0400] wrote:
On Mon, Apr 06, 2009 at 07:26:37PM +0200, Bernd Ahlers wrote:
quoted
@@ -871,13 +871,15 @@ unsigned long approxidate(const char *date)
 	struct timeval tv;
+	time_t time_sec;
[...]
 	gettimeofday(&tv, NULL);
-	localtime_r(&tv.tv_sec, &tm);
+	time_sec = tv.tv_sec;
+	localtime_r(&time_sec, &tm);
Hmph. According to POSIX, tv_sec _is_ a time_t. But I see on FreeBSD,
also, it is actually a "long". So I think this fix makes sense.
Okay. So what's the next step to get this committed? :)

Bernd

Re: [PATCH] 64-bit fix for date.c.

From: Jeff King <hidden>
Date: 2016-06-15 22:46:42

On Mon, May 04, 2009 at 04:26:14PM +0200, Bernd Ahlers wrote:
Jeff King [Mon, Apr 06, 2009 at 03:06:58PM -0400] wrote:
quoted
On Mon, Apr 06, 2009 at 07:26:37PM +0200, Bernd Ahlers wrote:
quoted
@@ -871,13 +871,15 @@ unsigned long approxidate(const char *date)
 	struct timeval tv;
+	time_t time_sec;
[...]
 	gettimeofday(&tv, NULL);
-	localtime_r(&tv.tv_sec, &tm);
+	time_sec = tv.tv_sec;
+	localtime_r(&time_sec, &tm);
Hmph. According to POSIX, tv_sec _is_ a time_t. But I see on FreeBSD,
also, it is actually a "long". So I think this fix makes sense.
Okay. So what's the next step to get this committed? :)
Looks like Junio missed it the first time around, so re-send it to him,
cc'ing the list. And you can add my

  Acked-by: Jeff King [off-list ref]

-Peff

Re: [PATCH] 64-bit fix for date.c.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:46:42

Jeff King [off-list ref] writes:
On Mon, May 04, 2009 at 04:26:14PM +0200, Bernd Ahlers wrote:
quoted
Jeff King [Mon, Apr 06, 2009 at 03:06:58PM -0400] wrote:
quoted
On Mon, Apr 06, 2009 at 07:26:37PM +0200, Bernd Ahlers wrote:
quoted
@@ -871,13 +871,15 @@ unsigned long approxidate(const char *date)
 	struct timeval tv;
+	time_t time_sec;
[...]
 	gettimeofday(&tv, NULL);
-	localtime_r(&tv.tv_sec, &tm);
+	time_sec = tv.tv_sec;
+	localtime_r(&time_sec, &tm);
Hmph. According to POSIX, tv_sec _is_ a time_t. But I see on FreeBSD,
also, it is actually a "long". So I think this fix makes sense.
Okay. So what's the next step to get this committed? :)
Looks like Junio missed it the first time around, so re-send it to him,
cc'ing the list. And you can add my

  Acked-by: Jeff King [off-list ref]
Thanks.

Re: [PATCH] 64-bit fix for date.c.

From: Tony Finch <dot@dotat.at>
Date: 2016-06-15 22:46:42

Jeff King [Mon, Apr 06, 2009 at 03:06:58PM -0400] wrote:
Hmph. According to POSIX, tv_sec _is_ a time_t. But I see on FreeBSD,
also, it is actually a "long". So I think this fix makes sense.
FreeBSD-7 has time_t tv_sec.

Tony.
-- 
f.anthony.n.finch  [off-list ref]  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.

Re: [PATCH] 64-bit fix for date.c.

From: Jeff King <hidden>
Date: 2016-06-15 22:46:43

On Wed, May 06, 2009 at 03:26:36PM +0100, Tony Finch wrote:
Jeff King [Mon, Apr 06, 2009 at 03:06:58PM -0400] wrote:
quoted
Hmph. According to POSIX, tv_sec _is_ a time_t. But I see on FreeBSD,
also, it is actually a "long". So I think this fix makes sense.
FreeBSD-7 has time_t tv_sec.
Thanks for the data point (I had looked at FreeBSD 6). I think this fix
still makes sense, though, as it should work on either type (and we
need to support the older platforms, too).

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help