summaryrefslogtreecommitdiffstats
path: root/term-utils/script.c
diff options
context:
space:
mode:
authorIsaac Dunham2015-10-16 03:12:59 +0200
committerKarel Zak2015-10-16 11:31:22 +0200
commit345208a5abb876deb451c481a5bab94b009eafe8 (patch)
tree1e0207ebfdd35158352f1803af2efaeb0fd38b3c /term-utils/script.c
parentsulogin: Use fallback method on the Hurd for detecting consoles (diff)
downloadkernel-qcow2-util-linux-345208a5abb876deb451c481a5bab94b009eafe8.tar.gz
kernel-qcow2-util-linux-345208a5abb876deb451c481a5bab94b009eafe8.tar.xz
kernel-qcow2-util-linux-345208a5abb876deb451c481a5bab94b009eafe8.zip
script: don't assume that time_t is compatible with long
time_t may change to 64-bit on 32-bit Linux kernels at some point; at that point, it may be desireable to test for issues with dates past 2038. [kzak@redhat.com: - use %jd rather than %lld] Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils/script.c')
-rw-r--r--term-utils/script.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/term-utils/script.c b/term-utils/script.c
index eb4ddc353..67ed8b9ca 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -141,11 +141,13 @@ static void script_init_debug(void)
static inline time_t script_time(time_t *t)
{
const char *str = getenv("SCRIPT_TEST_SECOND_SINCE_EPOCH");
- time_t sec;
+ int64_t sec;
- if (str && sscanf(str, "%ld", &sec) == 1)
- return sec;
- return time(t);
+ if (!str || sscanf(str, "%jd", &sec) != 1)
+ return time(t);
+ if (t)
+ *t = (time_t)sec;
+ return (time_t)sec;
}
#else /* !TEST_SCRIPT */
# define script_time(x) time(x)