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