pgreco / rpms / cockpit

Forked from forks/areguera/rpms/cockpit 4 years ago
Clone

Blame SOURCES/0002-bridge-Fix-format-string-type-mismatch-on-some-archi.patch

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