time_t on 32bit arch is not uint64_t. Even if it always were, it would be ugly to make such an assumption (without a static assert). Copy the value to a time_t variable first. Signed-off-by: Thomas Haller <thaller@xxxxxxxxxx> --- src/meta.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/meta.c b/src/meta.c index 822c2fd12b6f..0d4ae0261ff2 100644 --- a/src/meta.c +++ b/src/meta.c @@ -385,20 +385,23 @@ const struct datatype ifname_type = { static void date_type_print(const struct expr *expr, struct output_ctx *octx) { - uint64_t tstamp = mpz_get_uint64(expr->value); + uint64_t tstamp64 = mpz_get_uint64(expr->value); + time_t tstamp; struct tm *tm, *cur_tm; char timestr[21]; /* Convert from nanoseconds to seconds */ - tstamp /= 1000000000L; + tstamp64 /= 1000000000L; /* Obtain current tm, to add tm_gmtoff to the timestamp */ - cur_tm = localtime((time_t *) &tstamp); + tstamp = tstamp64; + cur_tm = localtime(&tstamp); if (cur_tm) - tstamp += cur_tm->tm_gmtoff; + tstamp64 += cur_tm->tm_gmtoff; - if ((tm = gmtime((time_t *) &tstamp)) != NULL && + tstamp = tstamp64; + if ((tm = gmtime(&tstamp)) != NULL && strftime(timestr, sizeof(timestr) - 1, "%Y-%m-%d %T", tm)) nft_print(octx, "\"%s\"", timestr); else -- 2.41.0