[libvirt] [PATCH v3] virfile: fix cast-align error

Bjoern Walk posted 1 patch 5 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20181010080404.169159-1-bwalk@linux.ibm.com
src/util/virfile.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
[libvirt] [PATCH v3] virfile: fix cast-align error
Posted by Bjoern Walk 5 years, 5 months ago
From: Marc Hartmayer <mhartmay@linux.ibm.com>

On s390x the struct member f_type of statsfs is hard coded to 'unsigned
int'. Change virFileIsSharedFixFUSE() to take a 'long long int' and use
a temporary to avoid pointer-casting.

This fixes the following error:
../../src/util/virfile.c:3578:38: error: cast increases required alignment of target type [-Werror=cast-align]
         virFileIsSharedFixFUSE(path, (long *) &sb.f_type);

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
---
 src/util/virfile.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index 2a7e8710..067ca569 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3466,7 +3466,7 @@ int virFilePrintf(FILE *fp, const char *msg, ...)
 
 static int
 virFileIsSharedFixFUSE(const char *path,
-                       long *f_type)
+                       long long *f_type)
 {
     char *dirpath = NULL;
     const char **mounts = NULL;
@@ -3537,6 +3537,7 @@ virFileIsSharedFSType(const char *path,
     char *p;
     struct statfs sb;
     int statfs_ret;
+    long long f_type = 0;
 
     if (VIR_STRDUP(dirpath, path) < 0)
         return -1;
@@ -3573,32 +3574,34 @@ virFileIsSharedFSType(const char *path,
         return -1;
     }
 
-    if (sb.f_type == FUSE_SUPER_MAGIC) {
+    f_type = sb.f_type;
+
+    if (f_type == FUSE_SUPER_MAGIC) {
         VIR_DEBUG("Found FUSE mount for path=%s. Trying to fix it", path);
-        virFileIsSharedFixFUSE(path, (long *) &sb.f_type);
+        virFileIsSharedFixFUSE(path, &f_type);
     }
 
     VIR_DEBUG("Check if path %s with FS magic %lld is shared",
-              path, (long long int)sb.f_type);
+              path, f_type);
 
     if ((fstypes & VIR_FILE_SHFS_NFS) &&
-        (sb.f_type == NFS_SUPER_MAGIC))
+        (f_type == NFS_SUPER_MAGIC))
         return 1;
 
     if ((fstypes & VIR_FILE_SHFS_GFS2) &&
-        (sb.f_type == GFS2_MAGIC))
+        (f_type == GFS2_MAGIC))
         return 1;
     if ((fstypes & VIR_FILE_SHFS_OCFS) &&
-        (sb.f_type == OCFS2_SUPER_MAGIC))
+        (f_type == OCFS2_SUPER_MAGIC))
         return 1;
     if ((fstypes & VIR_FILE_SHFS_AFS) &&
-        (sb.f_type == AFS_FS_MAGIC))
+        (f_type == AFS_FS_MAGIC))
         return 1;
     if ((fstypes & VIR_FILE_SHFS_SMB) &&
-        (sb.f_type == SMB_SUPER_MAGIC))
+        (f_type == SMB_SUPER_MAGIC))
         return 1;
     if ((fstypes & VIR_FILE_SHFS_CIFS) &&
-        (sb.f_type == CIFS_SUPER_MAGIC))
+        (f_type == CIFS_SUPER_MAGIC))
         return 1;
 
     return 0;
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3] virfile: fix cast-align error
Posted by Michal Privoznik 5 years, 5 months ago
On 10/10/2018 10:04 AM, Bjoern Walk wrote:
> From: Marc Hartmayer <mhartmay@linux.ibm.com>
> 
> On s390x the struct member f_type of statsfs is hard coded to 'unsigned
> int'. Change virFileIsSharedFixFUSE() to take a 'long long int' and use
> a temporary to avoid pointer-casting.
> 
> This fixes the following error:
> ../../src/util/virfile.c:3578:38: error: cast increases required alignment of target type [-Werror=cast-align]
>          virFileIsSharedFixFUSE(path, (long *) &sb.f_type);
> 
> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
> ---
>  src/util/virfile.c | 23 +++++++++++++----------
>  1 file changed, 13 insertions(+), 10 deletions(-)

ACKed and pushed.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3] virfile: fix cast-align error
Posted by Bjoern Walk 5 years, 5 months ago
Michal Privoznik <mprivozn@redhat.com> [2018-10-10, 05:35PM +0200]:
> On 10/10/2018 10:04 AM, Bjoern Walk wrote:
> > From: Marc Hartmayer <mhartmay@linux.ibm.com>
> > 
> > On s390x the struct member f_type of statsfs is hard coded to 'unsigned
> > int'. Change virFileIsSharedFixFUSE() to take a 'long long int' and use
> > a temporary to avoid pointer-casting.
> > 
> > This fixes the following error:
> > ../../src/util/virfile.c:3578:38: error: cast increases required alignment of target type [-Werror=cast-align]
> >          virFileIsSharedFixFUSE(path, (long *) &sb.f_type);
> > 
> > Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> > Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
> > ---
> >  src/util/virfile.c | 23 +++++++++++++----------
> >  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> ACKed and pushed.

Thanks a lot!

-- 
IBM Systems
Linux on Z & Virtualization Development
--------------------------------------------------
IBM Deutschland Research & Development GmbH
Schönaicher Str. 220, 71032 Böblingen
Phone: +49 7031 16 1819
--------------------------------------------------
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294 
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list