[libvirt] [RFC] virfile: fix cast-align error
Bjoern Walk
bwalk at linux.ibm.com
Tue Oct 9 08:54:17 UTC 2018
Marc Hartmayer <mhartmay at linux.ibm.com> [2018-10-08, 08:41PM +0200]:
> Use the correct type in order to fix the following error on s390x:
>
> In function 'virFileIsSharedFSType':
> ../../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 at linux.ibm.com>
> ---
> src/util/virfile.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/util/virfile.c b/src/util/virfile.c
> index 2a7e87102a25..832d832696d5 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)
> + unsigned int *f_type)
> {
> char *dirpath = NULL;
> const char **mounts = NULL;
> @@ -3575,7 +3575,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);
> }
Using an unsigned int is fine as per statfs(2):
NOTES
The __fsword_t type used for various fields in the statfs structure defini‐
tion is a glibc internal type, not intended for public use. This leaves
the programmer in a bit of a conundrum when trying to copy or compare these
fields to local variables in a program. Using unsigned int for such vari‐
ables suffices on most systems.
I would prefer an explicit cast though.
>
> VIR_DEBUG("Check if path %s with FS magic %lld is shared",
> path, (long long int)sb.f_type);
Should we also fix this cast?
Reviewed-by: Bjoern Walk <bwalk at linux.ibm.com>
--
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 902 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20181009/c13957ea/attachment-0001.sig>
More information about the libvir-list
mailing list