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