From c418074360a2055be8e337beb384c83b3a0344fd Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 7 May 2021 10:09:40 +0000 Subject: [PATCH] virtio-devices: vhost_user: fs: Don't reference packed struct error: reference to packed field is unaligned --> virtio-devices/src/vhost_user/fs.rs:85:21 | 85 | fs.flags[i].bits() as i32, | ^^^^^^^^^^^ | = note: `-D unaligned-references` implied by `-D warnings` = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) Signed-off-by: Rob Bradford --- virtio-devices/src/vhost_user/fs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virtio-devices/src/vhost_user/fs.rs b/virtio-devices/src/vhost_user/fs.rs index 1cd566166..d5aca8f25 100644 --- a/virtio-devices/src/vhost_user/fs.rs +++ b/virtio-devices/src/vhost_user/fs.rs @@ -78,11 +78,12 @@ impl VhostUserMasterReqHandler for SlaveReqHandler { } let addr = self.mmap_cache_addr + offset; + let flags = fs.flags[i]; let ret = unsafe { libc::mmap( addr as *mut libc::c_void, len as usize, - fs.flags[i].bits() as i32, + flags.bits() as i32, libc::MAP_SHARED | libc::MAP_FIXED, fd, fs.fd_offset[i] as libc::off_t,