src/util/virfile.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
On s390x the struct member f_type of statsfs is hard coded to
'unsigned int'. So let's try to determine the type by means of the GNU
extension typeof.
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>
---
src/util/virfile.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 2a7e87102a25..6cde4ab6c23b 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3464,9 +3464,15 @@ int virFilePrintf(FILE *fp, const char *msg, ...)
# define PROC_MOUNTS "/proc/mounts"
+# ifdef __GNUC__
+typedef typeof(((struct statfs*)0)->f_type) f_type_type;
+# else
+typedef long f_type_type;
+# endif
+
static int
virFileIsSharedFixFUSE(const char *path,
- long *f_type)
+ f_type_type *f_type)
{
char *dirpath = NULL;
const char **mounts = NULL;
@@ -3575,7 +3581,7 @@ virFileIsSharedFSType(const char *path,
if (sb.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, &sb.f_type);
}
VIR_DEBUG("Check if path %s with FS magic %lld is shared",
--
2.17.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Tue, Oct 09, 2018 at 05:55:29PM +0200, Marc Hartmayer wrote: > On s390x the struct member f_type of statsfs is hard coded to > 'unsigned int'. So let's try to determine the type by means of the GNU > extension typeof. > > 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> > --- > src/util/virfile.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/src/util/virfile.c b/src/util/virfile.c > index 2a7e87102a25..6cde4ab6c23b 100644 > --- a/src/util/virfile.c > +++ b/src/util/virfile.c > @@ -3464,9 +3464,15 @@ int virFilePrintf(FILE *fp, const char *msg, ...) > > # define PROC_MOUNTS "/proc/mounts" > > +# ifdef __GNUC__ > +typedef typeof(((struct statfs*)0)->f_type) f_type_type; > +# else > +typedef long f_type_type; > +# endif These games are rather overkill IMHO. > + > static int > virFileIsSharedFixFUSE(const char *path, > - long *f_type) > + f_type_type *f_type) Make this 'long long' > { > char *dirpath = NULL; > const char **mounts = NULL; > @@ -3575,7 +3581,7 @@ virFileIsSharedFSType(const char *path, Add a local variable long long f_type; and then after the stat() call f_type = sb.f_type; and change everything that follows to use the local variable > if (sb.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, &sb.f_type); > } > > VIR_DEBUG("Check if path %s with FS magic %lld is shared", This also removes the need to cast to long long in this VIR_DEBUG call Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2023 Red Hat, Inc.