lnav icon indicating copy to clipboard operation
lnav copied to clipboard

Fix printing of `time_t` values.

Open he32 opened this issue 2 years ago • 0 comments

There is no guarantee that time_t is a long int. On NetBSD, time_t is a long long int. And ... apparently there is no portable way to indicate a printf format for a time_t via sys/inttypes.h / int_fmtio.h.

So do the next best thing to improve portability to NetBSD and avoid the warning about mismatched format and argument type (-Wformat) by casting time_t to long long before printing, and use %lld as the format specifier.

In a similar vein, there's also no portable way to specify a suitable format for a size_t, so cast to long unsigned int and print with %lu.

he32 avatar May 24 '23 23:05 he32