Skip to content

Commit

Permalink
virtio-devices: vhost_user: fs: Don't reference packed struct
Browse files Browse the repository at this point in the history
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
<rust-lang/rust#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 <robert.bradford@intel.com>
  • Loading branch information
rbradford committed May 7, 2021
1 parent dfc7d6a commit d54010b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion virtio-devices/src/vhost_user/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d54010b

Please sign in to comment.