render / rpms / libvirt

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