From 70a82905148e571dc2d49f270ce10bcf039ec1b9 Mon Sep 17 00:00:00 2001 From: Dylan Reid Date: Thu, 12 Oct 2017 18:42:01 -0700 Subject: [PATCH] Fix new warning with rust 1.21 Mutable references being declared mutable themselves is unnecessary and now generates a warning. Change-Id: I29c7652fb86e17a8eda21efc728dd09b726c304f Signed-off-by: Dylan Reid Reviewed-on: https://chromium-review.googlesource.com/717733 Reviewed-by: Stephen Barber Reviewed-by: Zach Reizner --- net_util/src/lib.rs | 2 +- sys_util/src/mmap.rs | 2 +- x86_64/src/regs.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net_util/src/lib.rs b/net_util/src/lib.rs index 5c54687de7..76de2ef072 100644 --- a/net_util/src/lib.rs +++ b/net_util/src/lib.rs @@ -92,7 +92,7 @@ impl Tap { unsafe { let ifrn_name = ifreq.ifr_ifrn.ifrn_name.as_mut(); let ifru_flags = ifreq.ifr_ifru.ifru_flags.as_mut(); - let mut name_slice = &mut ifrn_name[..TUNTAP_DEV_FORMAT.len()]; + let name_slice = &mut ifrn_name[..TUNTAP_DEV_FORMAT.len()]; name_slice.copy_from_slice(TUNTAP_DEV_FORMAT); *ifru_flags = (net_sys::IFF_TAP | net_sys::IFF_NO_PI | net_sys::IFF_VNET_HDR) as c_short; diff --git a/sys_util/src/mmap.rs b/sys_util/src/mmap.rs index 13526d5380..1d9ac9ecbc 100644 --- a/sys_util/src/mmap.rs +++ b/sys_util/src/mmap.rs @@ -251,7 +251,7 @@ impl MemoryMapping { // It is safe to overwrite the volatile memory. Acessing the guest // memory as a mutable slice is OK because nothing assumes another // thread won't change what is loaded. - let mut dst = &mut self.as_mut_slice()[mem_offset..mem_end]; + let dst = &mut self.as_mut_slice()[mem_offset..mem_end]; src.read_exact(dst).map_err(Error::ReadFromSource)?; } Ok(()) diff --git a/x86_64/src/regs.rs b/x86_64/src/regs.rs index 1be0adf8fa..cfe6de3f9d 100644 --- a/x86_64/src/regs.rs +++ b/x86_64/src/regs.rs @@ -104,7 +104,7 @@ pub fn setup_msrs(vcpu: &kvm::Vcpu) -> Result<()> { let vec_size_bytes = mem::size_of::() + (entry_vec.len() * mem::size_of::()); let vec: Vec = Vec::with_capacity(vec_size_bytes); - let mut msrs: &mut kvm_msrs = unsafe { + let msrs: &mut kvm_msrs = unsafe { // Converting the vector's memory to a struct is unsafe. Carefully using the read-only // vector to size and set the members ensures no out-of-bounds erros below. &mut *(vec.as_ptr() as *mut kvm_msrs)