summaryrefslogtreecommitdiff
path: root/libarchive/archive_write_set_format_warc.c
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2022-12-20 04:48:42 -0800
committerGitHub <noreply@github.com>2022-12-20 13:48:42 +0100
commit2d329073435d36065ce30bfd29428f6a45e41016 (patch)
tree66cf347dc278eb7a86ac02dfabb8858d8fd69538 /libarchive/archive_write_set_format_warc.c
parent3da2fb7ee2d929bc8f02bcf3d42def768667c939 (diff)
downloadlibarchive-2d329073435d36065ce30bfd29428f6a45e41016.tar.gz
cleanup _localtime64_s (#1820)
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'libarchive/archive_write_set_format_warc.c')
-rw-r--r--libarchive/archive_write_set_format_warc.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/libarchive/archive_write_set_format_warc.c b/libarchive/archive_write_set_format_warc.c
index 46b05734..6f0a45d8 100644
--- a/libarchive/archive_write_set_format_warc.c
+++ b/libarchive/archive_write_set_format_warc.c
@@ -332,27 +332,18 @@ xstrftime(struct archive_string *as, const char *fmt, time_t t)
#if defined(HAVE_GMTIME_R) || defined(HAVE__GMTIME64_S)
struct tm timeHere;
#endif
-#if defined(HAVE__GMTIME64_S)
- errno_t terr;
- __time64_t tmptime;
-#endif
char strtime[100];
size_t len;
-#ifdef HAVE_GMTIME_R
- if ((rt = gmtime_r(&t, &timeHere)) == NULL)
- return;
-#elif defined(HAVE__GMTIME64_S)
- tmptime = t;
- terr = _gmtime64_s(&timeHere, &tmptime);
- if (terr)
- rt = NULL;
- else
- rt = &timeHere;
+#if defined(HAVE__GMTIME64_S)
+ rt = _gmtime64_s(&timeHere, &t) ? NULL : &timeHere;
+#elif defined(HAVE_GMTIME_R)
+ rt = gmtime_r(&t, &timeHere);
#else
- if ((rt = gmtime(&t)) == NULL)
- return;
+ rt = gmtime(&t);
#endif
+ if (!rt)
+ return;
/* leave the hard yacker to our role model strftime() */
len = strftime(strtime, sizeof(strtime)-1, fmt, rt);
archive_strncat(as, strtime, len);