summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorнаб <[email protected]>2020-05-21 21:53:13 +0200
committerBrian Behlendorf <[email protected]>2020-05-28 10:29:58 -0700
commita1ba12092744ce4da5ffb8061223cc61c9b8b4f8 (patch)
tree1c18232044b312664ffab83aa68690278e703bb9 /lib
parent6059f3a1f6950bd2aa9724ab917f2bc01343a076 (diff)
Always use "%lld" for formatting time_ts
Given the following test program: #include <time.h> #include <stdio.h> #include <stdint.h> int main() { printf("time_t: %d\n", sizeof(time_t)); printf("long: %d\n", sizeof(long)); printf("long long: %d\n", sizeof(long long)); } These are output on various x86 architectures: x32$ time_t: 8 x32$ long: 4 x32$ long long: 8 amd64$ time_t: 8 amd64$ long: 8 amd64$ long long: 8 i386$ time_t: 4 i386$ long: 4 i386$ long long: 8 Therefore code using "%l[du]" to format time_ts produced warnings on x32 Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #10357 Closes #844
Diffstat (limited to 'lib')
-rw-r--r--lib/libspl/timestamp.c2
-rw-r--r--lib/libzfs/libzfs_sendrecv.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/libspl/timestamp.c b/lib/libspl/timestamp.c
index eab15f3f1..22ecb3940 100644
--- a/lib/libspl/timestamp.c
+++ b/lib/libspl/timestamp.c
@@ -51,7 +51,7 @@ print_timestamp(uint_t timestamp_fmt)
fmt = nl_langinfo(_DATE_FMT);
if (timestamp_fmt == UDATE) {
- (void) printf("%ld\n", t);
+ (void) printf("%lld\n", (longlong_t)t);
} else if (timestamp_fmt == DDATE) {
char dstr[64];
int len;
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c
index c65673dd3..39b5c6df1 100644
--- a/lib/libzfs/libzfs_sendrecv.c
+++ b/lib/libzfs/libzfs_sendrecv.c
@@ -4888,8 +4888,8 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
zfs_nicebytes(bytes, buf1, sizeof (buf1));
zfs_nicebytes(bytes/delta, buf2, sizeof (buf1));
- (void) printf("received %s stream in %lu seconds (%s/sec)\n",
- buf1, delta, buf2);
+ (void) printf("received %s stream in %lld seconds (%s/sec)\n",
+ buf1, (longlong_t)delta, buf2);
}
err = 0;