summaryrefslogtreecommitdiff
path: root/archive-zip.c
diff options
context:
space:
mode:
authorDoan Tran Cong Danh <congdanhqx@gmail.com>2019-11-28 12:25:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-11-30 21:50:51 (GMT)
commitb5ab03bcb617897f9edce3d24cbc26f5e21b8f59 (patch)
tree0c8cf989f0528fa8882e60565be69ab068236260 /archive-zip.c
parentccd469450aaf62e6d0ce41a9738823d19d749a78 (diff)
downloadgit-b5ab03bcb617897f9edce3d24cbc26f5e21b8f59.zip
git-b5ab03bcb617897f9edce3d24cbc26f5e21b8f59.tar.gz
git-b5ab03bcb617897f9edce3d24cbc26f5e21b8f59.tar.bz2
archive-zip.c: switch to reentrant localtime_r
Originally, git was intended to be single-thread executable. `localtime(3)' can be used in such codebase for cleaner code. Overtime, we're employing multithread in our code base. Let's phase out `gmtime(3)' in favour of `localtime_r(3)'. Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'archive-zip.c')
-rw-r--r--archive-zip.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/archive-zip.c b/archive-zip.c
index 4d66b5b..313c6b9 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -603,18 +603,18 @@ static void write_zip_trailer(const struct object_id *oid)
static void dos_time(timestamp_t *timestamp, int *dos_date, int *dos_time)
{
time_t time;
- struct tm *t;
+ struct tm tm;
if (date_overflows(*timestamp))
die(_("timestamp too large for this system: %"PRItime),
*timestamp);
time = (time_t)*timestamp;
- t = localtime(&time);
+ localtime_r(&time, &tm);
*timestamp = time;
- *dos_date = t->tm_mday + (t->tm_mon + 1) * 32 +
- (t->tm_year + 1900 - 1980) * 512;
- *dos_time = t->tm_sec / 2 + t->tm_min * 32 + t->tm_hour * 2048;
+ *dos_date = tm.tm_mday + (tm.tm_mon + 1) * 32 +
+ (tm.tm_year + 1900 - 1980) * 512;
+ *dos_time = tm.tm_sec / 2 + tm.tm_min * 32 + tm.tm_hour * 2048;
}
static int archive_zip_config(const char *var, const char *value, void *data)