@matheusbsbs / matheus-bagliano / commits / b5ab03bcb6
Fork 0

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>

Doan Tran Cong Danh committed Nov 28, 2019 at 19:25 UTC b5ab03bcb617897f9edce3d24cbc26f5e21b8f59
1 file changed +5 -5
archive-zip.c
+5 -5
@@ -603,18 +603,18 @@ static void write_zip_trailer(const struct object_id *oid)
603 static void dos_time(timestamp_t *timestamp, int *dos_date, int *dos_time)
604 {
605 time_t time;
606 - struct tm *t;
606 + struct tm tm;
607
608 if (date_overflows(*timestamp))
609 die(_("timestamp too large for this system: %"PRItime),
610 *timestamp);
611 time = (time_t)*timestamp;
612 - t = localtime(&time);
612 + localtime_r(&time, &tm);
613 *timestamp = time;
614
615 - *dos_date = t->tm_mday + (t->tm_mon + 1) * 32 +
616 - (t->tm_year + 1900 - 1980) * 512;
617 - *dos_time = t->tm_sec / 2 + t->tm_min * 32 + t->tm_hour * 2048;
615 + *dos_date = tm.tm_mday + (tm.tm_mon + 1) * 32 +
616 + (tm.tm_year + 1900 - 1980) * 512;
617 + *dos_time = tm.tm_sec / 2 + tm.tm_min * 32 + tm.tm_hour * 2048;
618 }
619
620 static int archive_zip_config(const char *var, const char *value, void *data)