a5a3f0
From 5b47ca781fddf2704b55370acf7cc369ae049c64 Mon Sep 17 00:00:00 2001
a5a3f0
Message-Id: <5b47ca781fddf2704b55370acf7cc369ae049c64@dist-git>
a5a3f0
From: Marc Hartmayer <mhartmay@linux.ibm.com>
a5a3f0
Date: Wed, 10 Oct 2018 17:25:52 +0200
a5a3f0
Subject: [PATCH] virfile: fix cast-align error
a5a3f0
a5a3f0
RHEL-7.7: https://bugzilla.redhat.com/show_bug.cgi?id=1632711
a5a3f0
RHEL-8.0: https://bugzilla.redhat.com/show_bug.cgi?id=1634782
a5a3f0
RHEL-7.6.z: https://bugzilla.redhat.com/show_bug.cgi?id=1635705
a5a3f0
a5a3f0
On s390x the struct member f_type of statsfs is hard coded to 'unsigned
a5a3f0
int'. Change virFileIsSharedFixFUSE() to take a 'long long int' and use
a5a3f0
a temporary to avoid pointer-casting.
a5a3f0
a5a3f0
This fixes the following error:
a5a3f0
../../src/util/virfile.c:3578:38: error: cast increases required alignment of target type [-Werror=cast-align]
a5a3f0
         virFileIsSharedFixFUSE(path, (long *) &sb.f_type);
a5a3f0
a5a3f0
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
a5a3f0
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
a5a3f0
(cherry picked from commit 2b03534eeb2f3f41865538cd4c3e5d326260ad27)
a5a3f0
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
a5a3f0
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
a5a3f0
---
a5a3f0
 src/util/virfile.c | 23 +++++++++++++----------
a5a3f0
 1 file changed, 13 insertions(+), 10 deletions(-)
a5a3f0
a5a3f0
diff --git a/src/util/virfile.c b/src/util/virfile.c
a5a3f0
index c87e26bf5b..46466ed136 100644
a5a3f0
--- a/src/util/virfile.c
a5a3f0
+++ b/src/util/virfile.c
a5a3f0
@@ -3542,7 +3542,7 @@ int virFilePrintf(FILE *fp, const char *msg, ...)
a5a3f0
 
a5a3f0
 static int
a5a3f0
 virFileIsSharedFixFUSE(const char *path,
a5a3f0
-                       long *f_type)
a5a3f0
+                       long long *f_type)
a5a3f0
 {
a5a3f0
     char *dirpath = NULL;
a5a3f0
     const char **mounts = NULL;
a5a3f0
@@ -3612,6 +3612,7 @@ virFileIsSharedFSType(const char *path,
a5a3f0
     char *dirpath, *p;
a5a3f0
     struct statfs sb;
a5a3f0
     int statfs_ret;
a5a3f0
+    long long f_type = 0;
a5a3f0
 
a5a3f0
     if (VIR_STRDUP(dirpath, path) < 0)
a5a3f0
         return -1;
a5a3f0
@@ -3651,32 +3652,34 @@ virFileIsSharedFSType(const char *path,
a5a3f0
         return -1;
a5a3f0
     }
a5a3f0
 
a5a3f0
-    if (sb.f_type == FUSE_SUPER_MAGIC) {
a5a3f0
+    f_type = sb.f_type;
a5a3f0
+
a5a3f0
+    if (f_type == FUSE_SUPER_MAGIC) {
a5a3f0
         VIR_DEBUG("Found FUSE mount for path=%s. Trying to fix it", path);
a5a3f0
-        virFileIsSharedFixFUSE(path, (long *) &sb.f_type);
a5a3f0
+        virFileIsSharedFixFUSE(path, &f_type);
a5a3f0
     }
a5a3f0
 
a5a3f0
     VIR_DEBUG("Check if path %s with FS magic %lld is shared",
a5a3f0
-              path, (long long int)sb.f_type);
a5a3f0
+              path, f_type);
a5a3f0
 
a5a3f0
     if ((fstypes & VIR_FILE_SHFS_NFS) &&
a5a3f0
-        (sb.f_type == NFS_SUPER_MAGIC))
a5a3f0
+        (f_type == NFS_SUPER_MAGIC))
a5a3f0
         return 1;
a5a3f0
 
a5a3f0
     if ((fstypes & VIR_FILE_SHFS_GFS2) &&
a5a3f0
-        (sb.f_type == GFS2_MAGIC))
a5a3f0
+        (f_type == GFS2_MAGIC))
a5a3f0
         return 1;
a5a3f0
     if ((fstypes & VIR_FILE_SHFS_OCFS) &&
a5a3f0
-        (sb.f_type == OCFS2_SUPER_MAGIC))
a5a3f0
+        (f_type == OCFS2_SUPER_MAGIC))
a5a3f0
         return 1;
a5a3f0
     if ((fstypes & VIR_FILE_SHFS_AFS) &&
a5a3f0
-        (sb.f_type == AFS_FS_MAGIC))
a5a3f0
+        (f_type == AFS_FS_MAGIC))
a5a3f0
         return 1;
a5a3f0
     if ((fstypes & VIR_FILE_SHFS_SMB) &&
a5a3f0
-        (sb.f_type == SMB_SUPER_MAGIC))
a5a3f0
+        (f_type == SMB_SUPER_MAGIC))
a5a3f0
         return 1;
a5a3f0
     if ((fstypes & VIR_FILE_SHFS_CIFS) &&
a5a3f0
-        (sb.f_type == CIFS_SUPER_MAGIC))
a5a3f0
+        (f_type == CIFS_SUPER_MAGIC))
a5a3f0
         return 1;
a5a3f0
 
a5a3f0
     return 0;
a5a3f0
-- 
a5a3f0
2.19.1
a5a3f0