git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] 64-bit fix for date.c.
@ 2009-04-06 17:26 Bernd Ahlers
  2009-04-06 19:06 ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Bernd Ahlers @ 2009-04-06 17:26 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] 64-bit fix for date.c.
  2009-04-06 17:26 [PATCH] 64-bit fix for date.c Bernd Ahlers
@ 2009-04-06 19:06 ` Jeff King
  2009-05-04 14:26   ` Bernd Ahlers
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2009-04-06 19:06 UTC (permalink / raw)
  To: Bernd Ahlers; +Cc: git

On Mon, Apr 06, 2009 at 07:26:37PM +0200, Bernd Ahlers wrote:

> @@ -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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] 64-bit fix for date.c.
  2009-04-06 19:06 ` Jeff King
@ 2009-05-04 14:26   ` Bernd Ahlers
  2009-05-04 14:31     ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Bernd Ahlers @ 2009-05-04 14:26 UTC (permalink / raw)
  To: Jeff King; +Cc: git

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:
>
>> @@ -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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] 64-bit fix for date.c.
  2009-05-04 14:26   ` Bernd Ahlers
@ 2009-05-04 14:31     ` Jeff King
  2009-05-06  5:51       ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2009-05-04 14:31 UTC (permalink / raw)
  To: Bernd Ahlers; +Cc: git

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:
> >On Mon, Apr 06, 2009 at 07:26:37PM +0200, Bernd Ahlers wrote:
> >
> >> @@ -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 <peff@peff.net>

-Peff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] 64-bit fix for date.c.
  2009-05-04 14:31     ` Jeff King
@ 2009-05-06  5:51       ` Junio C Hamano
  2009-05-06 14:26         ` Tony Finch
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2009-05-06  5:51 UTC (permalink / raw)
  To: Jeff King; +Cc: Bernd Ahlers, git

Jeff King <peff@peff.net> writes:

> 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:
>> >On Mon, Apr 06, 2009 at 07:26:37PM +0200, Bernd Ahlers wrote:
>> >
>> >> @@ -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 <peff@peff.net>

Thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] 64-bit fix for date.c.
  2009-05-06  5:51       ` Junio C Hamano
@ 2009-05-06 14:26         ` Tony Finch
  2009-05-06 16:49           ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Tony Finch @ 2009-05-06 14:26 UTC (permalink / raw)
  To: Jeff King; +Cc: git

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  <dot@dotat.at>  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] 64-bit fix for date.c.
  2009-05-06 14:26         ` Tony Finch
@ 2009-05-06 16:49           ` Jeff King
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff King @ 2009-05-06 16:49 UTC (permalink / raw)
  To: Tony Finch; +Cc: git

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:
> >
> >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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-05-06 16:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-06 17:26 [PATCH] 64-bit fix for date.c Bernd Ahlers
2009-04-06 19:06 ` Jeff King
2009-05-04 14:26   ` Bernd Ahlers
2009-05-04 14:31     ` Jeff King
2009-05-06  5:51       ` Junio C Hamano
2009-05-06 14:26         ` Tony Finch
2009-05-06 16:49           ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).