Re: loadables/finfo: fix time_t printing

2022-12-09 Thread Chet Ramey

On 12/8/22 2:19 PM, Christian Weisgerber wrote:

loadables/finfo.c uses the %ld format string to print time_t values.
This is wrong on OpenBSD, where time_t is long long on all platforms.

I suggest %lld and a cast to long long.
Alternatively, %jd and intmax_t could be used.


Thanks for the report. I chose the second option.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




loadables/finfo: fix time_t printing

2022-12-08 Thread Christian Weisgerber
loadables/finfo.c uses the %ld format string to print time_t values.
This is wrong on OpenBSD, where time_t is long long on all platforms.

I suggest %lld and a cast to long long.
Alternatively, %jd and intmax_t could be used.

--- examples/loadables/finfo.c.orig Mon Jun 29 16:56:32 2020
+++ examples/loadables/finfo.c  Thu Dec  8 16:24:34 2022
@@ -328,17 +328,17 @@
if (flags & OPT_ASCII)
printf("%s", ctime(>st_atime));
else
-   printf("%ld\n", st->st_atime);
+   printf("%lld\n", (long long)st->st_atime);
} else if (flags & OPT_MTIME) {
if (flags & OPT_ASCII)
printf("%s", ctime(>st_mtime));
else
-   printf("%ld\n", st->st_mtime);
+   printf("%lld\n", (long long)st->st_mtime);
} else if (flags & OPT_CTIME) {
if (flags & OPT_ASCII)
printf("%s", ctime(>st_ctime));
else
-   printf("%ld\n", st->st_ctime);
+   printf("%lld\n", (long long)st->st_ctime);
} else if (flags & OPT_DEV)
printf("%lu\n", (unsigned long)st->st_dev);
else if (flags & OPT_INO)
-- 
Christian "naddy" Weisgerber  na...@mips.inka.de