From f697b33b015fcb0c90210840eb4ef8e6a18d4bdf Mon Sep 17 00:00:00 2001 From: Bernd Ahlers Date: Mon, 6 Apr 2009 19:26:37 +0200 Subject: [PATCH] Work around BSD whose typeof(tv.tv_sec) != time_t According to POSIX, tv_sec is supposed to be a time_t, but OpenBSD (and FreeBSD, too) defines it to be a long, which triggers a type mismatch when a pointer to it is given to localtime_r(). Acked-by: Jeff King Signed-off-by: Junio C Hamano --- date.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/date.c b/date.c index 1165d30ad..409a17d46 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; -- 2.30.2