render / rpms / libvirt

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