From 2e9bcba70685383426ad42c8856c50ce3214ae24 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Wed, 28 Dec 2022 14:05:16 -0800 Subject: further cleanup _localtime64_s (#1824) These were missing from 2d329073435d36065ce30bfd29428f6a45e41016 Signed-off-by: Rosen Penev Signed-off-by: Rosen Penev --- cpio/cpio.c | 11 +---------- cpio/test/test_option_t.c | 11 +---------- libarchive/test/test_write_format_zip_compression_store.c | 11 +---------- libarchive/test/test_write_format_zip_file.c | 11 +---------- libarchive/test/test_write_format_zip_file_zip64.c | 11 +---------- tar/util.c | 11 +---------- test_utils/test_main.c | 11 +---------- 7 files changed, 7 insertions(+), 70 deletions(-) diff --git a/cpio/cpio.c b/cpio/cpio.c index 7ed6a823..de0144fa 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -1156,10 +1156,6 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry) #if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) struct tm tmbuf; #endif -#if defined(HAVE__LOCALTIME64_S) - errno_t terr; - __time64_t tmptime; -#endif if (!now) time(&now); @@ -1208,12 +1204,7 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry) fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M"; #endif #if defined(HAVE__LOCALTIME64_S) - tmptime = mtime; - terr = _localtime64_s(&tmbuf, &tmptime); - if (terr) - ltime = NULL; - else - ltime = &tmbuf; + ltime = _localtime64_s(&tmbuf, &mtime) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) ltime = localtime_r(&mtime, &tmbuf); #else diff --git a/cpio/test/test_option_t.c b/cpio/test/test_option_t.c index 3d27b72d..52bcff52 100644 --- a/cpio/test/test_option_t.c +++ b/cpio/test/test_option_t.c @@ -40,10 +40,6 @@ DEFINE_TEST(test_option_t) #if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) struct tm tmbuf; #endif -#if defined(HAVE__LOCALTIME64_S) - errno_t terr; - __time64_t tmptime; -#endif /* List reference archive, make sure the TOC is correct. */ extract_reference_file("test_option_t.cpio"); @@ -96,12 +92,7 @@ DEFINE_TEST(test_option_t) setlocale(LC_ALL, ""); #endif #if defined(HAVE__LOCALTIME64_S) - tmptime = mtime; - terr = _localtime64_s(&tmbuf, &tmptime); - if (terr) - tmptr = NULL; - else - tmptr = &tmbuf; + tmptr = _localtime64_s(&tmbuf, &mtime) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tmptr = localtime_r(&mtime, &tmbuf); #else diff --git a/libarchive/test/test_write_format_zip_compression_store.c b/libarchive/test/test_write_format_zip_compression_store.c index aae50afb..4d086edf 100644 --- a/libarchive/test/test_write_format_zip_compression_store.c +++ b/libarchive/test/test_write_format_zip_compression_store.c @@ -131,22 +131,13 @@ static void verify_uncompressed_contents(const char *buff, size_t used) struct tm *tm; #if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) struct tm tmbuf; -#endif -#if defined(HAVE__LOCALTIME64_S) - errno_t terr; - __time64_t tmptime; #endif /* p is the pointer to walk over the central directory, * q walks over the local headers, the data and the data descriptors. */ const char *p, *q, *local_header, *extra_start; #if defined(HAVE__LOCALTIME64_S) - tmptime = now; - terr = _localtime64_s(&tmbuf, &tmptime); - if (terr) - tm = NULL; - else - tm = &tmbuf; + tm = _localtime64_s(&tmbuf, &now) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&now, &tmbuf); #else diff --git a/libarchive/test/test_write_format_zip_file.c b/libarchive/test/test_write_format_zip_file.c index ff3c13dc..afd0eb6e 100644 --- a/libarchive/test/test_write_format_zip_file.c +++ b/libarchive/test/test_write_format_zip_file.c @@ -76,10 +76,6 @@ DEFINE_TEST(test_write_format_zip_file) struct tm *tm; #if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) struct tm tmbuf; -#endif -#if defined(HAVE__LOCALTIME64_S) - errno_t terr; - __time64_t tmptime; #endif size_t used, buffsize = 1000000; unsigned long crc; @@ -99,12 +95,7 @@ DEFINE_TEST(test_write_format_zip_file) #endif #if defined(HAVE__LOCALTIME64_S) - tmptime = t; - terr = _localtime64_s(&tmbuf, &tmptime); - if (terr) - tm = NULL; - else - tm = &tmbuf; + tm = _localtime64_s(&tmbuf, &t) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&t, &tmbuf); #else diff --git a/libarchive/test/test_write_format_zip_file_zip64.c b/libarchive/test/test_write_format_zip_file_zip64.c index 8e3b12e1..8a506226 100644 --- a/libarchive/test/test_write_format_zip_file_zip64.c +++ b/libarchive/test/test_write_format_zip_file_zip64.c @@ -78,10 +78,6 @@ DEFINE_TEST(test_write_format_zip_file_zip64) struct tm *tm; #if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) struct tm tmbuf; -#endif -#if defined(HAVE__LOCALTIME64_S) - errno_t terr; - __time64_t tmptime; #endif size_t used, buffsize = 1000000; unsigned long crc; @@ -100,12 +96,7 @@ DEFINE_TEST(test_write_format_zip_file_zip64) #endif #if defined(HAVE__LOCALTIME64_S) - tmptime = t; - terr = _localtime64_s(&tmbuf, &tmptime); - if (terr) - tm = NULL; - else - tm = &tmbuf; + tm = _localtime64_s(&tmbuf, &t) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&t, &tmbuf); #else diff --git a/tar/util.c b/tar/util.c index 6ce26c13..9664c16b 100644 --- a/tar/util.c +++ b/tar/util.c @@ -671,10 +671,6 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) #if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) struct tm tmbuf; #endif -#if defined(HAVE__LOCALTIME64_S) - errno_t terr; - __time64_t tmptime; -#endif /* * We avoid collecting the entire list in memory at once by @@ -747,12 +743,7 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) else fmt = bsdtar->day_first ? DAY_FMT " %b %H:%M" : "%b " DAY_FMT " %H:%M"; #if defined(HAVE__LOCALTIME64_S) - tmptime = tim; - terr = _localtime64_s(&tmbuf, &tmptime); - if (terr) - ltime = NULL; - else - ltime = &tmbuf; + ltime = _localtime64_s(&tmbuf, &tim) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) ltime = localtime_r(&tim, &tmbuf); #else diff --git a/test_utils/test_main.c b/test_utils/test_main.c index a733c9e5..81b5002f 100644 --- a/test_utils/test_main.c +++ b/test_utils/test_main.c @@ -3870,10 +3870,6 @@ main(int argc, char **argv) struct tm *tmptr; #if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) struct tm tmbuf; -#endif -#if defined(HAVE__LOCALTIME64_S) - errno_t terr; - __time64_t tmptime; #endif char *refdir_alloc = NULL; const char *progname; @@ -4110,12 +4106,7 @@ main(int argc, char **argv) now = time(NULL); for (i = 0; ; i++) { #if defined(HAVE__LOCALTIME64_S) - tmptime = now; - terr = _localtime64_s(&tmbuf, &tmptime); - if (terr) - tmptr = NULL; - else - tmptr = &tmbuf; + tmptr = _localtime64_s(&tmbuf, &now) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tmptr = localtime_r(&now, &tmbuf); #else -- cgit v1.2.1