@matheusbsbs / matheus-bagliano / commits / 84b0115f0d
Fork 0

compat: remove gmtime

ccd469450a (date.c: switch to reentrant {gm,local}time_r, 2019-11-28) removes the only gmtime() call we had and moves to gmtime_r() which doesn't have the same portability problems. Remove the compat gmtime code since it is no longer needed, and confirm by successfull running t4212 in FreeBSD 9.3 amd64 (the oldest I could get a hold off). Further work might be needed to ensure 32bit time_t systems (like FreeBSD i386) will handle correctly the overflows tested in t4212, but that is orthogonal to this change, and it doesn't change the current behaviour as neither gmtime() or gmtime_r() will ever return NULL on those systems because time_t is unsigned. Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Carlo Marcelo Arenas Belón committed May 14, 2020 at 12:18 UTC 84b0115f0dc9483dbc7f064b46afaddc4d94db92
4 files changed -45
Makefile
-8
@@ -405,9 +405,6 @@ all::
405 # with a different indexfile format version. If it isn't set the index
406 # file format used is index-v[23].
407 #
408 -# Define GMTIME_UNRELIABLE_ERRORS if your gmtime() function does not
409 -# return NULL when it receives a bogus time_t.
410 -#
408 # Define HAVE_CLOCK_GETTIME if your platform has clock_gettime.
409 #
410 # Define HAVE_CLOCK_MONOTONIC if your platform has CLOCK_MONOTONIC.
@@ -1801,11 +1798,6 @@ ifndef NO_MSGFMT_EXTENDED_OPTIONS
1798 MSGFMT += --check --statistics
1799 endif
1800
1804 -ifdef GMTIME_UNRELIABLE_ERRORS
1805 - COMPAT_OBJS += compat/gmtime.o
1806 - BASIC_CFLAGS += -DGMTIME_UNRELIABLE_ERRORS
1807 -endif
1808 -
1801 ifdef HAVE_CLOCK_GETTIME
1802 BASIC_CFLAGS += -DHAVE_CLOCK_GETTIME
1803 endif
compat/gmtime.c deleted
-29
@@ -1,29 +0,0 @@
1 -#include "../git-compat-util.h"
2 -#undef gmtime
3 -#undef gmtime_r
4 -
5 -struct tm *git_gmtime(const time_t *timep)
6 -{
7 - static struct tm result;
8 - return git_gmtime_r(timep, &result);
9 -}
10 -
11 -struct tm *git_gmtime_r(const time_t *timep, struct tm *result)
12 -{
13 - struct tm *ret;
14 -
15 - memset(result, 0, sizeof(*result));
16 - ret = gmtime_r(timep, result);
17 -
18 - /*
19 - * Rather than NULL, FreeBSD gmtime simply leaves the "struct tm"
20 - * untouched when it encounters overflow. Since "mday" cannot otherwise
21 - * be zero, we can test this very quickly.
22 - */
23 - if (ret && !ret->tm_mday) {
24 - ret = NULL;
25 - errno = EOVERFLOW;
26 - }
27 -
28 - return ret;
29 -}
config.mak.uname
-1
@@ -237,7 +237,6 @@ ifeq ($(uname_S),FreeBSD)
237 PYTHON_PATH = /usr/local/bin/python
238 PERL_PATH = /usr/local/bin/perl
239 HAVE_PATHS_H = YesPlease
240 - GMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes
240 HAVE_BSD_SYSCTL = YesPlease
241 HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
242 PAGER_ENV = LESS=FRX LV=-c MORE=FRX
git-compat-util.h
-7
@@ -1208,13 +1208,6 @@ int access_or_die(const char *path, int mode, unsigned flag);
1208 /* Warn on an inaccessible file if errno indicates this is an error */
1209 int warn_on_fopen_errors(const char *path);
1210
1211 -#ifdef GMTIME_UNRELIABLE_ERRORS
1212 -struct tm *git_gmtime(const time_t *);
1213 -struct tm *git_gmtime_r(const time_t *, struct tm *);
1214 -#define gmtime git_gmtime
1215 -#define gmtime_r git_gmtime_r
1216 -#endif
1217 -
1211 #if !defined(USE_PARENS_AROUND_GETTEXT_N) && defined(__GNUC__)
1212 #define USE_PARENS_AROUND_GETTEXT_N 1
1213 #endif