]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
further cleanup _localtime64_s (#1824)
authorRosen Penev <rosenp@gmail.com>
Wed, 28 Dec 2022 22:05:16 +0000 (14:05 -0800)
committerGitHub <noreply@github.com>
Wed, 28 Dec 2022 22:05:16 +0000 (23:05 +0100)
These were missing from 2d329073435d36065ce30bfd29428f6a45e41016

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
cpio/cpio.c
cpio/test/test_option_t.c
libarchive/test/test_write_format_zip_compression_store.c
libarchive/test/test_write_format_zip_file.c
libarchive/test/test_write_format_zip_file_zip64.c
tar/util.c
test_utils/test_main.c

index 7ed6a82357c7fa9999548a0dd84cdbe4a22f681e..de0144fa00d52e879955cdd3503ac61e23f6b676 100644 (file)
@@ -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
index 3d27b72dd52be7fc60bda52d5747a2aba9c4d70a..52bcff5233b79c0860fa65da1e14e5921811e2fa 100644 (file)
@@ -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
index aae50afb22640291cd2d2f27ccff240c97f7c7b3..4d086edf5c8bb3763bebb87572959fa788eb17e2 100644 (file)
@@ -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
index ff3c13dcef73baf201d366d328fb61bdd348bc88..afd0eb6e96f19f5fd48e369d5b2590b817229d3e 100644 (file)
@@ -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
index 8e3b12e166f6823eecea0bcdaa7bcbbf3507e41a..8a506226b8541690763981b56af303527637933d 100644 (file)
@@ -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
index 6ce26c133a1fc0163c37da74d96f5d7ae0ca7697..9664c16b4a86605079f972f623b8b513b99d604e 100644 (file)
@@ -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
index a733c9e56a5d2f029bad6876b0926e06d38191ea..81b5002f3bcc1b0d87b9e9c63b8126daa9735e6f 100644 (file)
@@ -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