summary refs log tree commit diff
path: root/src/plugin
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@chromium.org>2019-04-15 15:30:21 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-17 17:22:57 -0700
commit1c5e2557e2eb3992c320b658ef117cb578bc6fe1 (patch)
tree03c48568332467b36db736f8d173ead442c7963e /src/plugin
parent35ee9d918404ee87abdd23a450fdb483388e1932 (diff)
downloadcrosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.tar
crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.tar.gz
crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.tar.bz2
crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.tar.lz
crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.tar.xz
crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.tar.zst
crosvm-1c5e2557e2eb3992c320b658ef117cb578bc6fe1.zip
edition: Eliminate blocks superseded by NLL
Before the new borrow checker in the 2018 edition, we sometimes used to
have to manually insert curly braced blocks to limit the scope of
borrows. These are no longer needed.

Details in:

https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/non-lexical-lifetimes.html

TEST=cargo check --all-features
TEST=local kokoro

Change-Id: I59f9f98dcc03c8790c53e080a527ad9b68c8d6f3
Reviewed-on: https://chromium-review.googlesource.com/1568075
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'src/plugin')
-rw-r--r--src/plugin/vcpu.rs44
1 files changed, 20 insertions, 24 deletions
diff --git a/src/plugin/vcpu.rs b/src/plugin/vcpu.rs
index adbe7e1..1b65d43 100644
--- a/src/plugin/vcpu.rs
+++ b/src/plugin/vcpu.rs
@@ -343,17 +343,17 @@ impl PluginVcpu {
                 if offset >= len {
                     return false;
                 }
+
                 let mut wait_reason = VcpuResponse_Wait::new();
-                {
-                    let io = wait_reason.mut_io();
-                    io.space = match io_space {
-                        IoSpace::Ioport => AddressSpace::IOPORT,
-                        IoSpace::Mmio => AddressSpace::MMIO,
-                    };
-                    io.address = addr;
-                    io.is_write = data.is_write();
-                    io.data = data.as_slice().to_vec();
-                }
+                let io = wait_reason.mut_io();
+                io.space = match io_space {
+                    IoSpace::Ioport => AddressSpace::IOPORT,
+                    IoSpace::Mmio => AddressSpace::MMIO,
+                };
+                io.address = addr;
+                io.is_write = data.is_write();
+                io.data = data.as_slice().to_vec();
+
                 self.wait_reason.set(Some(wait_reason));
                 match self.handle_until_resume(vcpu) {
                     Ok(resume_data) => data.copy_from_slice(&resume_data),
@@ -478,21 +478,17 @@ impl PluginVcpu {
             response.mut_set_cpuid();
             let request_entries = &request.get_set_cpuid().entries;
             let mut cpuid = CpuId::new(request_entries.len());
-            {
-                let cpuid_entries = cpuid.mut_entries_slice();
-                for (request_entry, cpuid_entry) in
-                    request_entries.iter().zip(cpuid_entries.iter_mut())
-                {
-                    cpuid_entry.function = request_entry.function;
-                    if request_entry.has_index {
-                        cpuid_entry.index = request_entry.index;
-                        cpuid_entry.flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
-                    }
-                    cpuid_entry.eax = request_entry.eax;
-                    cpuid_entry.ebx = request_entry.ebx;
-                    cpuid_entry.ecx = request_entry.ecx;
-                    cpuid_entry.edx = request_entry.edx;
+            let cpuid_entries = cpuid.mut_entries_slice();
+            for (request_entry, cpuid_entry) in request_entries.iter().zip(cpuid_entries) {
+                cpuid_entry.function = request_entry.function;
+                if request_entry.has_index {
+                    cpuid_entry.index = request_entry.index;
+                    cpuid_entry.flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
                 }
+                cpuid_entry.eax = request_entry.eax;
+                cpuid_entry.ebx = request_entry.ebx;
+                cpuid_entry.ecx = request_entry.ecx;
+                cpuid_entry.edx = request_entry.edx;
             }
             vcpu.set_cpuid2(&cpuid)
         } else {