From 16a22bebb0bb4a28aec9ca76442af93462fc200e Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 17 Apr 2020 23:52:52 +0200 Subject: Remove some configure time sizeof checks In libtar, the sizeof time_t checked when trying to store a time value. It is pointless using the preprocessor here, as we can simply do an if (sizeof(time_t) < ...) check and the compiler will take care optimizing away one or the other branch. After changing the libtar check and the corresponding unit tests, the sizeof check can be removed from configure.ac, along with other unused sizeof checks. Signed-off-by: David Oberhollenzer --- lib/tar/internal.h | 1 + lib/tar/read_header.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'lib/tar') diff --git a/lib/tar/internal.h b/lib/tar/internal.h index 755d4eb..57746ae 100644 --- a/lib/tar/internal.h +++ b/lib/tar/internal.h @@ -13,6 +13,7 @@ #include #include +#include #include #include diff --git a/lib/tar/read_header.c b/lib/tar/read_header.c index 0591879..2918d09 100644 --- a/lib/tar/read_header.c +++ b/lib/tar/read_header.c @@ -155,17 +155,17 @@ static int decode_header(const tar_header_t *hdr, unsigned int set_by_pax, break; } -#if SIZEOF_TIME_T < 8 - if (out->mtime > (sqfs_s64)INT32_MAX) { - out->sb.st_mtime = INT32_MAX; - } else if (out->mtime < (sqfs_s64)INT32_MIN) { - out->sb.st_mtime = INT32_MIN; + if (sizeof(time_t) * CHAR_BIT < 64) { + if (out->mtime > (sqfs_s64)INT32_MAX) { + out->sb.st_mtime = INT32_MAX; + } else if (out->mtime < (sqfs_s64)INT32_MIN) { + out->sb.st_mtime = INT32_MIN; + } else { + out->sb.st_mtime = out->mtime; + } } else { out->sb.st_mtime = out->mtime; } -#else - out->sb.st_mtime = out->mtime; -#endif return 0; } -- cgit v1.2.3