From 9a92996334750d03cae64eddcb67297c334d4185 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Sun, 23 Apr 2017 22:31:14 +0200 Subject: [PATCH 02/23] bridge: Fix format string type mismatch on some architectures On some architectures a time_t is "long long", not "long", and compilation fails with src/bridge/cockpitfsread.c:120:38: error: format '%ld' expects argument of type 'long int', but argument 3 has type '__time_t {aka long long int}' [-Werror=format=] return g_strdup_printf ("1:%lu-%ld.%ld", Explicitly cast the time_t to long long which is 64 bit safe. At least on x32, struct timeval's tv_nsec is misdefined to be a long long, although the specification says "long". Work around this by explicitly casting to long, which is a no-op on most platforms and safe on x32 as tv_nsec never exceeds 1 billion. This works around . Reviewed-by: Peter --- src/bridge/cockpitfsread.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bridge/cockpitfsread.c b/src/bridge/cockpitfsread.c index 7838735..3b25d6e 100644 --- a/src/bridge/cockpitfsread.c +++ b/src/bridge/cockpitfsread.c @@ -117,10 +117,10 @@ file_tag_from_stat (int res, // renames. if (res >= 0) - return g_strdup_printf ("1:%lu-%ld.%ld", + return g_strdup_printf ("1:%lu-%lld.%ld", (unsigned long)buf->st_ino, - buf->st_mtim.tv_sec, - buf->st_mtim.tv_nsec); + (long long int)buf->st_mtim.tv_sec, + (long int)buf->st_mtim.tv_nsec); else if (err == ENOENT) return g_strdup ("-"); else -- 2.13.5