From b0df12edc007f22f4293e62e9fa3f6ae478449e1 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Wed, 12 Feb 2025 12:36:10 +0200 Subject: [PATCH] status: use %lld to print time_t Some build configurations are switching to 64-bit time_t, breaking builds on 32-bit architectures. Always use %lld and perform an explicit conversion to (long long int) in order to make the code compile on all architectures. ../status.c: In function 'status_send_values': ../status.c:46:53: error: format '%ld' expects argument of type 'long int', but argument 4 has type '__time64_t' {aka 'long long int'} [-Werror=format=] Signed-off-by: Dmitry Baryshkov --- status.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/status.c b/status.c index 431c04f..b2ef2eb 100644 --- a/status.c +++ b/status.c @@ -43,7 +43,8 @@ void status_send_values(const char *id, struct status_value *values) status_get_ts(&ts); - len = snprintf(buf, sizeof(buf), "{\"ts\":%ld.%03ld, \"%s\":{ ", ts.tv_sec, ts.tv_nsec / 1000000, id); + len = snprintf(buf, sizeof(buf), "{\"ts\":%lld.%03ld, \"%s\":{ ", + (long long int)ts.tv_sec, ts.tv_nsec / 1000000, id); for (value = values; value->unit; value++) { if (value != values) {