mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 10:10:41 +00:00
edition: Eliminate ref keyword
As described in: https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/default-match-bindings.html which also covers the new mental model that the Rust Book will use for teaching binding modes and has been found to be more friendly for both beginners and experienced users. Before: match *opt { Some(ref v) => ..., None => ..., } After: match opt { Some(v) => ..., None => ..., } TEST=cargo check --all-features TEST=local kokoro Change-Id: I3c5800a9be36aaf5d3290ae3bd3116f699cb00b7 Reviewed-on: https://chromium-review.googlesource.com/1566669 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>
This commit is contained in:
parent
b1de6323ab
commit
64cd5eae57
34 changed files with 261 additions and 263 deletions
|
@ -91,8 +91,8 @@ fn bitfield_tuple_struct_impl(ast: &DeriveInput, fields: &FieldsUnnamed) -> Resu
|
|||
));
|
||||
}
|
||||
|
||||
let field_type = match fields.unnamed.first().unwrap().value().ty {
|
||||
Type::Path(ref t) => t,
|
||||
let field_type = match &fields.unnamed.first().unwrap().value().ty {
|
||||
Type::Path(t) => t,
|
||||
_ => {
|
||||
return Err(Error::new(
|
||||
Span::call_site(),
|
||||
|
|
|
@ -669,7 +669,7 @@ impl PitCounter {
|
|||
// For square wave mode, this isn't quite accurate to the spec, but the
|
||||
// difference isn't meaningfully visible to the guest in any important way,
|
||||
// and the code is simpler without the special case.
|
||||
if let Some(ref mut interrupt) = self.interrupt_evt {
|
||||
if let Some(interrupt) = &mut self.interrupt_evt {
|
||||
// This is safe because the file descriptor is nonblocking and we're writing 1.
|
||||
interrupt.write(1).unwrap();
|
||||
}
|
||||
|
@ -686,9 +686,9 @@ impl PitCounter {
|
|||
}
|
||||
|
||||
fn get_ticks_passed(&self) -> u64 {
|
||||
match self.start {
|
||||
match &self.start {
|
||||
None => 0,
|
||||
Some(ref t) => {
|
||||
Some(t) => {
|
||||
let dur = self.clock.lock().now().duration_since(t);
|
||||
let dur_ns: u64 = dur.as_secs() * NANOS_PER_SEC + u64::from(dur.subsec_nanos());
|
||||
(dur_ns * FREQUENCY_HZ / NANOS_PER_SEC)
|
||||
|
|
|
@ -290,8 +290,8 @@ impl ProviderInner {
|
|||
UsbControlCommand::ListDevice { port } => {
|
||||
let port_number = port;
|
||||
let result = match self.usb_hub.get_port(port_number) {
|
||||
Some(port) => match *port.get_backend_device() {
|
||||
Some(ref device) => {
|
||||
Some(port) => match port.get_backend_device().as_ref() {
|
||||
Some(device) => {
|
||||
let vid = device.get_vid();
|
||||
let pid = device.get_pid();
|
||||
UsbControlResult::Device {
|
||||
|
|
|
@ -299,7 +299,7 @@ impl HostDevice {
|
|||
}
|
||||
XhciTransferState::Completed => {
|
||||
let status = t.status();
|
||||
if let Some(ref buffer) = buffer {
|
||||
if let Some(buffer) = &buffer {
|
||||
let _bytes = buffer
|
||||
.write(&t.buffer().data_buffer)
|
||||
.map_err(Error::WriteBuffer)?
|
||||
|
|
|
@ -430,8 +430,8 @@ impl DeviceSlot {
|
|||
.set_state(DeviceSlotState::Default);
|
||||
} else {
|
||||
let port = self.hub.get_port(port_id).ok_or(Error::GetPort(port_id))?;
|
||||
match *port.get_backend_device() {
|
||||
Some(ref mut backend) => {
|
||||
match port.get_backend_device().as_mut() {
|
||||
Some(backend) => {
|
||||
backend.set_address(self.slot_id as u32);
|
||||
}
|
||||
None => {
|
||||
|
|
|
@ -168,10 +168,8 @@ impl PciDevice for XhciController {
|
|||
}
|
||||
|
||||
fn keep_fds(&self) -> Vec<RawFd> {
|
||||
match self.state {
|
||||
XhciControllerState::Created {
|
||||
ref device_provider,
|
||||
} => device_provider.keep_fds(),
|
||||
match &self.state {
|
||||
XhciControllerState::Created { device_provider } => device_provider.keep_fds(),
|
||||
_ => {
|
||||
error!("xhci controller is in a wrong state");
|
||||
vec![]
|
||||
|
|
|
@ -21,15 +21,15 @@ pub trait FailHandle: Send + Sync {
|
|||
|
||||
impl FailHandle for Option<Arc<dyn FailHandle>> {
|
||||
fn fail(&self) {
|
||||
match *self {
|
||||
Some(ref handle) => handle.fail(),
|
||||
match self {
|
||||
Some(handle) => handle.fail(),
|
||||
None => error!("event loop trying to fail without a fail handle"),
|
||||
}
|
||||
}
|
||||
|
||||
fn failed(&self) -> bool {
|
||||
match &self {
|
||||
Some(ref handle) => handle.failed(),
|
||||
match self {
|
||||
Some(handle) => handle.failed(),
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -890,11 +890,11 @@ impl<T: 'static + AsRawFd + DiskFile + Send> VirtioDevice for Block<T> {
|
|||
fn keep_fds(&self) -> Vec<RawFd> {
|
||||
let mut keep_fds = Vec::new();
|
||||
|
||||
if let Some(ref disk_image) = self.disk_image {
|
||||
if let Some(disk_image) = &self.disk_image {
|
||||
keep_fds.push(disk_image.as_raw_fd());
|
||||
}
|
||||
|
||||
if let Some(ref control_socket) = self.control_socket {
|
||||
if let Some(control_socket) = &self.control_socket {
|
||||
keep_fds.push(control_socket.as_raw_fd());
|
||||
}
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ impl VirglResource for BackedBuffer {
|
|||
|
||||
fn attach_guest_backing(&mut self, mem: &GuestMemory, vecs: Vec<(GuestAddress, usize)>) {
|
||||
self.backing = vecs.clone();
|
||||
if let Some(ref mut resource) = self.gpu_renderer_resource {
|
||||
if let Some(resource) = &mut self.gpu_renderer_resource {
|
||||
if let Err(e) = resource.attach_backing(&vecs[..], mem) {
|
||||
error!("failed to attach backing to BackBuffer resource: {}", e);
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ impl VirglResource for BackedBuffer {
|
|||
}
|
||||
|
||||
fn detach_guest_backing(&mut self) {
|
||||
if let Some(ref mut resource) = self.gpu_renderer_resource {
|
||||
if let Some(resource) = &mut self.gpu_renderer_resource {
|
||||
resource.detach_backing();
|
||||
}
|
||||
self.backing.clear();
|
||||
|
@ -231,9 +231,9 @@ impl VirglResource for BackedBuffer {
|
|||
}
|
||||
|
||||
fn import_to_display(&mut self, display: &Rc<RefCell<GpuDisplay>>) -> Option<u32> {
|
||||
if let Some((ref self_display, import)) = self.display_import {
|
||||
if Rc::ptr_eq(&self_display, display) {
|
||||
return Some(import);
|
||||
if let Some((self_display, import)) = &self.display_import {
|
||||
if Rc::ptr_eq(self_display, display) {
|
||||
return Some(*import);
|
||||
}
|
||||
}
|
||||
let dmabuf = match self.buffer.export_plane_fd(0) {
|
||||
|
|
|
@ -515,7 +515,7 @@ impl Worker {
|
|||
}
|
||||
};
|
||||
|
||||
if let Some(ref resource_bridge) = self.resource_bridge {
|
||||
if let Some(resource_bridge) = &self.resource_bridge {
|
||||
if let Err(e) = poll_ctx.add(resource_bridge, Token::ResourceBridge) {
|
||||
error!("failed to add resource bridge to PollContext: {}", e);
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ impl Worker {
|
|||
// created or destroyed by the control queue. Processing the resource bridge first may
|
||||
// lead to a race condition.
|
||||
if process_resource_bridge {
|
||||
if let Some(ref resource_bridge) = self.resource_bridge {
|
||||
if let Some(resource_bridge) = &self.resource_bridge {
|
||||
self.state.process_resource_bridge(resource_bridge);
|
||||
}
|
||||
}
|
||||
|
@ -654,7 +654,7 @@ impl VirtioDevice for Gpu {
|
|||
keep_fds.push(libc::STDERR_FILENO);
|
||||
}
|
||||
keep_fds.push(self.exit_evt.as_raw_fd());
|
||||
if let Some(ref resource_bridge) = self.resource_bridge {
|
||||
if let Some(resource_bridge) = &self.resource_bridge {
|
||||
keep_fds.push(resource_bridge.as_raw_fd());
|
||||
}
|
||||
keep_fds
|
||||
|
|
|
@ -517,27 +517,27 @@ impl From<VolatileMemoryError> for GpuCommandDecodeError {
|
|||
impl fmt::Debug for GpuCommand {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use self::GpuCommand::*;
|
||||
match *self {
|
||||
GetDisplayInfo(ref _info) => f.debug_struct("GetDisplayInfo").finish(),
|
||||
ResourceCreate2d(ref _info) => f.debug_struct("ResourceCreate2d").finish(),
|
||||
ResourceUnref(ref _info) => f.debug_struct("ResourceUnref").finish(),
|
||||
SetScanout(ref _info) => f.debug_struct("SetScanout").finish(),
|
||||
ResourceFlush(ref _info) => f.debug_struct("ResourceFlush").finish(),
|
||||
TransferToHost2d(ref _info) => f.debug_struct("TransferToHost2d").finish(),
|
||||
ResourceAttachBacking(ref _info) => f.debug_struct("ResourceAttachBacking").finish(),
|
||||
ResourceDetachBacking(ref _info) => f.debug_struct("ResourceDetachBacking").finish(),
|
||||
GetCapsetInfo(ref _info) => f.debug_struct("GetCapsetInfo").finish(),
|
||||
GetCapset(ref _info) => f.debug_struct("GetCapset").finish(),
|
||||
CtxCreate(ref _info) => f.debug_struct("CtxCreate").finish(),
|
||||
CtxDestroy(ref _info) => f.debug_struct("CtxDestroy").finish(),
|
||||
CtxAttachResource(ref _info) => f.debug_struct("CtxAttachResource").finish(),
|
||||
CtxDetachResource(ref _info) => f.debug_struct("CtxDetachResource").finish(),
|
||||
ResourceCreate3d(ref _info) => f.debug_struct("ResourceCreate3d").finish(),
|
||||
TransferToHost3d(ref _info) => f.debug_struct("TransferToHost3d").finish(),
|
||||
TransferFromHost3d(ref _info) => f.debug_struct("TransferFromHost3d").finish(),
|
||||
CmdSubmit3d(ref _info) => f.debug_struct("CmdSubmit3d").finish(),
|
||||
UpdateCursor(ref _info) => f.debug_struct("UpdateCursor").finish(),
|
||||
MoveCursor(ref _info) => f.debug_struct("MoveCursor").finish(),
|
||||
match self {
|
||||
GetDisplayInfo(_info) => f.debug_struct("GetDisplayInfo").finish(),
|
||||
ResourceCreate2d(_info) => f.debug_struct("ResourceCreate2d").finish(),
|
||||
ResourceUnref(_info) => f.debug_struct("ResourceUnref").finish(),
|
||||
SetScanout(_info) => f.debug_struct("SetScanout").finish(),
|
||||
ResourceFlush(_info) => f.debug_struct("ResourceFlush").finish(),
|
||||
TransferToHost2d(_info) => f.debug_struct("TransferToHost2d").finish(),
|
||||
ResourceAttachBacking(_info) => f.debug_struct("ResourceAttachBacking").finish(),
|
||||
ResourceDetachBacking(_info) => f.debug_struct("ResourceDetachBacking").finish(),
|
||||
GetCapsetInfo(_info) => f.debug_struct("GetCapsetInfo").finish(),
|
||||
GetCapset(_info) => f.debug_struct("GetCapset").finish(),
|
||||
CtxCreate(_info) => f.debug_struct("CtxCreate").finish(),
|
||||
CtxDestroy(_info) => f.debug_struct("CtxDestroy").finish(),
|
||||
CtxAttachResource(_info) => f.debug_struct("CtxAttachResource").finish(),
|
||||
CtxDetachResource(_info) => f.debug_struct("CtxDetachResource").finish(),
|
||||
ResourceCreate3d(_info) => f.debug_struct("ResourceCreate3d").finish(),
|
||||
TransferToHost3d(_info) => f.debug_struct("TransferToHost3d").finish(),
|
||||
TransferFromHost3d(_info) => f.debug_struct("TransferFromHost3d").finish(),
|
||||
CmdSubmit3d(_info) => f.debug_struct("CmdSubmit3d").finish(),
|
||||
UpdateCursor(_info) => f.debug_struct("UpdateCursor").finish(),
|
||||
MoveCursor(_info) => f.debug_struct("MoveCursor").finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -575,27 +575,27 @@ impl GpuCommand {
|
|||
/// Gets the generic `virtio_gpu_ctrl_hdr` from this command.
|
||||
pub fn ctrl_hdr(&self) -> &virtio_gpu_ctrl_hdr {
|
||||
use self::GpuCommand::*;
|
||||
match *self {
|
||||
GetDisplayInfo(ref info) => &info,
|
||||
ResourceCreate2d(ref info) => &info.hdr,
|
||||
ResourceUnref(ref info) => &info.hdr,
|
||||
SetScanout(ref info) => &info.hdr,
|
||||
ResourceFlush(ref info) => &info.hdr,
|
||||
TransferToHost2d(ref info) => &info.hdr,
|
||||
ResourceAttachBacking(ref info) => &info.hdr,
|
||||
ResourceDetachBacking(ref info) => &info.hdr,
|
||||
GetCapsetInfo(ref info) => &info.hdr,
|
||||
GetCapset(ref info) => &info.hdr,
|
||||
CtxCreate(ref info) => &info.hdr,
|
||||
CtxDestroy(ref info) => &info.hdr,
|
||||
CtxAttachResource(ref info) => &info.hdr,
|
||||
CtxDetachResource(ref info) => &info.hdr,
|
||||
ResourceCreate3d(ref info) => &info.hdr,
|
||||
TransferToHost3d(ref info) => &info.hdr,
|
||||
TransferFromHost3d(ref info) => &info.hdr,
|
||||
CmdSubmit3d(ref info) => &info.hdr,
|
||||
UpdateCursor(ref info) => &info.hdr,
|
||||
MoveCursor(ref info) => &info.hdr,
|
||||
match self {
|
||||
GetDisplayInfo(info) => info,
|
||||
ResourceCreate2d(info) => &info.hdr,
|
||||
ResourceUnref(info) => &info.hdr,
|
||||
SetScanout(info) => &info.hdr,
|
||||
ResourceFlush(info) => &info.hdr,
|
||||
TransferToHost2d(info) => &info.hdr,
|
||||
ResourceAttachBacking(info) => &info.hdr,
|
||||
ResourceDetachBacking(info) => &info.hdr,
|
||||
GetCapsetInfo(info) => &info.hdr,
|
||||
GetCapset(info) => &info.hdr,
|
||||
CtxCreate(info) => &info.hdr,
|
||||
CtxDestroy(info) => &info.hdr,
|
||||
CtxAttachResource(info) => &info.hdr,
|
||||
CtxDetachResource(info) => &info.hdr,
|
||||
ResourceCreate3d(info) => &info.hdr,
|
||||
TransferToHost3d(info) => &info.hdr,
|
||||
TransferFromHost3d(info) => &info.hdr,
|
||||
CmdSubmit3d(info) => &info.hdr,
|
||||
UpdateCursor(info) => &info.hdr,
|
||||
MoveCursor(info) => &info.hdr,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -597,7 +597,7 @@ where
|
|||
T: 'static + EventSource + Send,
|
||||
{
|
||||
fn keep_fds(&self) -> Vec<RawFd> {
|
||||
if let Some(ref source) = self.source {
|
||||
if let Some(source) = &self.source {
|
||||
return vec![source.as_raw_fd()];
|
||||
}
|
||||
Vec::new()
|
||||
|
|
|
@ -435,11 +435,11 @@ where
|
|||
fn keep_fds(&self) -> Vec<RawFd> {
|
||||
let mut keep_fds = Vec::new();
|
||||
|
||||
if let Some(ref tap) = self.tap {
|
||||
if let Some(tap) = &self.tap {
|
||||
keep_fds.push(tap.as_raw_fd());
|
||||
}
|
||||
|
||||
if let Some(ref workers_kill_evt) = self.workers_kill_evt {
|
||||
if let Some(workers_kill_evt) = &self.workers_kill_evt {
|
||||
keep_fds.push(workers_kill_evt.as_raw_fd());
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ impl VirtioDevice for Rng {
|
|||
fn keep_fds(&self) -> Vec<RawFd> {
|
||||
let mut keep_fds = Vec::new();
|
||||
|
||||
if let Some(ref random_file) = self.random_file {
|
||||
if let Some(random_file) = &self.random_file {
|
||||
keep_fds.push(random_file.as_raw_fd());
|
||||
}
|
||||
|
||||
|
|
|
@ -115,19 +115,19 @@ where
|
|||
fn keep_fds(&self) -> Vec<RawFd> {
|
||||
let mut keep_fds = Vec::new();
|
||||
|
||||
if let Some(ref tap) = self.tap {
|
||||
if let Some(tap) = &self.tap {
|
||||
keep_fds.push(tap.as_raw_fd());
|
||||
}
|
||||
|
||||
if let Some(ref vhost_net_handle) = self.vhost_net_handle {
|
||||
if let Some(vhost_net_handle) = &self.vhost_net_handle {
|
||||
keep_fds.push(vhost_net_handle.as_raw_fd());
|
||||
}
|
||||
|
||||
if let Some(ref vhost_interrupt) = self.vhost_interrupt {
|
||||
if let Some(vhost_interrupt) = &self.vhost_interrupt {
|
||||
keep_fds.push(vhost_interrupt.as_raw_fd());
|
||||
}
|
||||
|
||||
if let Some(ref workers_kill_evt) = self.workers_kill_evt {
|
||||
if let Some(workers_kill_evt) = &self.workers_kill_evt {
|
||||
keep_fds.push(workers_kill_evt.as_raw_fd());
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ impl Drop for Vsock {
|
|||
fn drop(&mut self) {
|
||||
// Only kill the child if it claimed its eventfd.
|
||||
if self.worker_kill_evt.is_none() {
|
||||
if let Some(ref kill_evt) = self.kill_evt {
|
||||
if let Some(kill_evt) = &self.kill_evt {
|
||||
// Ignore the result because there is nothing we can do about it.
|
||||
let _ = kill_evt.write(1);
|
||||
}
|
||||
|
@ -88,15 +88,15 @@ impl VirtioDevice for Vsock {
|
|||
fn keep_fds(&self) -> Vec<RawFd> {
|
||||
let mut keep_fds = Vec::new();
|
||||
|
||||
if let Some(ref handle) = self.vhost_handle {
|
||||
if let Some(handle) = &self.vhost_handle {
|
||||
keep_fds.push(handle.as_raw_fd());
|
||||
}
|
||||
|
||||
if let Some(ref interrupt) = self.interrupt {
|
||||
if let Some(interrupt) = &self.interrupt {
|
||||
keep_fds.push(interrupt.as_raw_fd());
|
||||
}
|
||||
|
||||
if let Some(ref worker_kill_evt) = self.worker_kill_evt {
|
||||
if let Some(worker_kill_evt) = &self.worker_kill_evt {
|
||||
keep_fds.push(worker_kill_evt.as_raw_fd());
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ impl<T: Vhost> Worker<T> {
|
|||
.set_mem_table()
|
||||
.map_err(Error::VhostSetMemTable)?;
|
||||
|
||||
for (queue_index, ref queue) in self.queues.iter().enumerate() {
|
||||
for (queue_index, queue) in self.queues.iter().enumerate() {
|
||||
self.vhost_handle
|
||||
.set_vring_num(queue_index, queue.max_size)
|
||||
.map_err(Error::VhostSetVringNum)?;
|
||||
|
|
|
@ -302,10 +302,10 @@ impl PciDevice for VirtioPciDevice {
|
|||
|
||||
fn keep_fds(&self) -> Vec<RawFd> {
|
||||
let mut fds = self.device.keep_fds();
|
||||
if let Some(ref interrupt_evt) = self.interrupt_evt {
|
||||
if let Some(interrupt_evt) = &self.interrupt_evt {
|
||||
fds.push(interrupt_evt.as_raw_fd());
|
||||
}
|
||||
if let Some(ref interrupt_resample_evt) = self.interrupt_resample_evt {
|
||||
if let Some(interrupt_resample_evt) = &self.interrupt_resample_evt {
|
||||
fds.push(interrupt_resample_evt.as_raw_fd());
|
||||
}
|
||||
fds
|
||||
|
|
|
@ -692,16 +692,16 @@ struct WlVfd {
|
|||
impl fmt::Debug for WlVfd {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "WlVfd {{")?;
|
||||
if let Some(ref s) = self.socket {
|
||||
if let Some(s) = &self.socket {
|
||||
write!(f, " socket: {}", s.as_raw_fd())?;
|
||||
}
|
||||
if let Some(&(slot, pfn, _)) = self.slot.as_ref() {
|
||||
if let Some((slot, pfn, _)) = &self.slot {
|
||||
write!(f, " slot: {} pfn: {}", slot, pfn)?;
|
||||
}
|
||||
if let Some(ref s) = self.remote_pipe {
|
||||
if let Some(s) = &self.remote_pipe {
|
||||
write!(f, " remote: {}", s.as_raw_fd())?;
|
||||
}
|
||||
if let Some((_, ref s)) = self.local_pipe {
|
||||
if let Some((_, s)) = &self.local_pipe {
|
||||
write!(f, " local: {}", s.as_raw_fd())?;
|
||||
}
|
||||
write!(f, " }}")
|
||||
|
@ -781,8 +781,8 @@ impl WlVfd {
|
|||
return Err(WlError::DmabufSync(io::Error::from_raw_os_error(EINVAL)));
|
||||
}
|
||||
|
||||
match self.guest_shared_memory.as_ref() {
|
||||
Some(&(_, ref fd)) => {
|
||||
match &self.guest_shared_memory {
|
||||
Some((_, fd)) => {
|
||||
let sync = dma_buf_sync {
|
||||
flags: flags as u64,
|
||||
};
|
||||
|
@ -885,25 +885,25 @@ impl WlVfd {
|
|||
fn send_fd(&self) -> Option<RawFd> {
|
||||
self.guest_shared_memory
|
||||
.as_ref()
|
||||
.map(|&(_, ref fd)| fd.as_raw_fd())
|
||||
.map(|(_, fd)| fd.as_raw_fd())
|
||||
.or(self.socket.as_ref().map(|s| s.as_raw_fd()))
|
||||
.or(self.remote_pipe.as_ref().map(|p| p.as_raw_fd()))
|
||||
}
|
||||
|
||||
// The FD that is used for polling for events on this VFD.
|
||||
fn poll_fd(&self) -> Option<&dyn AsRawFd> {
|
||||
self.socket.as_ref().map(|s| s as &dyn AsRawFd).or(self
|
||||
.local_pipe
|
||||
self.socket
|
||||
.as_ref()
|
||||
.map(|&(_, ref p)| p as &dyn AsRawFd))
|
||||
.map(|s| s as &dyn AsRawFd)
|
||||
.or(self.local_pipe.as_ref().map(|(_, p)| p as &dyn AsRawFd))
|
||||
}
|
||||
|
||||
// Sends data/files from the guest to the host over this VFD.
|
||||
fn send(&mut self, fds: &[RawFd], data: VolatileSlice) -> WlResult<WlResp> {
|
||||
if let Some(ref socket) = self.socket {
|
||||
if let Some(socket) = &self.socket {
|
||||
socket.send_with_fds(data, fds).map_err(WlError::SendVfd)?;
|
||||
Ok(WlResp::Ok)
|
||||
} else if let Some((_, ref mut local_pipe)) = self.local_pipe {
|
||||
} else if let Some((_, local_pipe)) = &mut self.local_pipe {
|
||||
// Impossible to send fds over a simple pipe.
|
||||
if !fds.is_empty() {
|
||||
return Ok(WlResp::InvalidType);
|
||||
|
@ -1187,10 +1187,10 @@ impl WlState {
|
|||
|
||||
fn close(&mut self, vfd_id: u32) -> WlResult<WlResp> {
|
||||
let mut to_delete = Set::new();
|
||||
for &(dest_vfd_id, ref q) in self.in_queue.iter() {
|
||||
if dest_vfd_id == vfd_id {
|
||||
if let WlRecv::Vfd { id } = *q {
|
||||
to_delete.insert(id);
|
||||
for (dest_vfd_id, q) in self.in_queue.iter() {
|
||||
if *dest_vfd_id == vfd_id {
|
||||
if let WlRecv::Vfd { id } = q {
|
||||
to_delete.insert(*id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1710,10 +1710,10 @@ impl VirtioDevice for Wl {
|
|||
fn keep_fds(&self) -> Vec<RawFd> {
|
||||
let mut keep_fds = Vec::new();
|
||||
|
||||
if let Some(ref vm_socket) = self.vm_socket {
|
||||
if let Some(vm_socket) = &self.vm_socket {
|
||||
keep_fds.push(vm_socket.as_raw_fd());
|
||||
}
|
||||
if let Some(ref resource_bridge) = self.resource_bridge {
|
||||
if let Some(resource_bridge) = &self.resource_bridge {
|
||||
keep_fds.push(resource_bridge.as_raw_fd());
|
||||
}
|
||||
|
||||
|
|
|
@ -150,8 +150,8 @@ fn testable_derive(input: DeriveInput) -> proc_macro2::TokenStream {
|
|||
|
||||
let signature;
|
||||
let value;
|
||||
match repr {
|
||||
Some(ref repr) => {
|
||||
match &repr {
|
||||
Some(repr) => {
|
||||
signature = quote! {
|
||||
fn n(value: #repr)
|
||||
};
|
||||
|
|
|
@ -42,7 +42,7 @@ fn socket_msg_impl(input: DeriveInput) -> TokenStream {
|
|||
|
||||
fn is_named_struct(ds: &DataStruct) -> bool {
|
||||
match &ds.fields {
|
||||
&Fields::Named(ref _f) => true,
|
||||
Fields::Named(_f) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -671,7 +671,7 @@ mod tests {
|
|||
match res {
|
||||
// We won't have permission in test environments; allow that
|
||||
Ok(_t) => {}
|
||||
Err(Error::IoctlError(ref e)) if e.errno() == EPERM => {}
|
||||
Err(Error::IoctlError(e)) if e.errno() == EPERM => {}
|
||||
Err(e) => panic!("Unexpected Error:\n{}", e),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,35 +124,35 @@ pub struct Tframe {
|
|||
|
||||
impl WireFormat for Tframe {
|
||||
fn byte_size(&self) -> u32 {
|
||||
let msg_size = match self.msg {
|
||||
Tmessage::Version(ref version) => version.byte_size(),
|
||||
Tmessage::Flush(ref flush) => flush.byte_size(),
|
||||
Tmessage::Walk(ref walk) => walk.byte_size(),
|
||||
Tmessage::Read(ref read) => read.byte_size(),
|
||||
Tmessage::Write(ref write) => write.byte_size(),
|
||||
Tmessage::Clunk(ref clunk) => clunk.byte_size(),
|
||||
Tmessage::Remove(ref remove) => remove.byte_size(),
|
||||
Tmessage::Attach(ref attach) => attach.byte_size(),
|
||||
Tmessage::Auth(ref auth) => auth.byte_size(),
|
||||
Tmessage::Statfs(ref statfs) => statfs.byte_size(),
|
||||
Tmessage::Lopen(ref lopen) => lopen.byte_size(),
|
||||
Tmessage::Lcreate(ref lcreate) => lcreate.byte_size(),
|
||||
Tmessage::Symlink(ref symlink) => symlink.byte_size(),
|
||||
Tmessage::Mknod(ref mknod) => mknod.byte_size(),
|
||||
Tmessage::Rename(ref rename) => rename.byte_size(),
|
||||
Tmessage::Readlink(ref readlink) => readlink.byte_size(),
|
||||
Tmessage::GetAttr(ref getattr) => getattr.byte_size(),
|
||||
Tmessage::SetAttr(ref setattr) => setattr.byte_size(),
|
||||
Tmessage::XattrWalk(ref xattrwalk) => xattrwalk.byte_size(),
|
||||
Tmessage::XattrCreate(ref xattrcreate) => xattrcreate.byte_size(),
|
||||
Tmessage::Readdir(ref readdir) => readdir.byte_size(),
|
||||
Tmessage::Fsync(ref fsync) => fsync.byte_size(),
|
||||
Tmessage::Lock(ref lock) => lock.byte_size(),
|
||||
Tmessage::GetLock(ref getlock) => getlock.byte_size(),
|
||||
Tmessage::Link(ref link) => link.byte_size(),
|
||||
Tmessage::Mkdir(ref mkdir) => mkdir.byte_size(),
|
||||
Tmessage::RenameAt(ref renameat) => renameat.byte_size(),
|
||||
Tmessage::UnlinkAt(ref unlinkat) => unlinkat.byte_size(),
|
||||
let msg_size = match &self.msg {
|
||||
Tmessage::Version(version) => version.byte_size(),
|
||||
Tmessage::Flush(flush) => flush.byte_size(),
|
||||
Tmessage::Walk(walk) => walk.byte_size(),
|
||||
Tmessage::Read(read) => read.byte_size(),
|
||||
Tmessage::Write(write) => write.byte_size(),
|
||||
Tmessage::Clunk(clunk) => clunk.byte_size(),
|
||||
Tmessage::Remove(remove) => remove.byte_size(),
|
||||
Tmessage::Attach(attach) => attach.byte_size(),
|
||||
Tmessage::Auth(auth) => auth.byte_size(),
|
||||
Tmessage::Statfs(statfs) => statfs.byte_size(),
|
||||
Tmessage::Lopen(lopen) => lopen.byte_size(),
|
||||
Tmessage::Lcreate(lcreate) => lcreate.byte_size(),
|
||||
Tmessage::Symlink(symlink) => symlink.byte_size(),
|
||||
Tmessage::Mknod(mknod) => mknod.byte_size(),
|
||||
Tmessage::Rename(rename) => rename.byte_size(),
|
||||
Tmessage::Readlink(readlink) => readlink.byte_size(),
|
||||
Tmessage::GetAttr(getattr) => getattr.byte_size(),
|
||||
Tmessage::SetAttr(setattr) => setattr.byte_size(),
|
||||
Tmessage::XattrWalk(xattrwalk) => xattrwalk.byte_size(),
|
||||
Tmessage::XattrCreate(xattrcreate) => xattrcreate.byte_size(),
|
||||
Tmessage::Readdir(readdir) => readdir.byte_size(),
|
||||
Tmessage::Fsync(fsync) => fsync.byte_size(),
|
||||
Tmessage::Lock(lock) => lock.byte_size(),
|
||||
Tmessage::GetLock(getlock) => getlock.byte_size(),
|
||||
Tmessage::Link(link) => link.byte_size(),
|
||||
Tmessage::Mkdir(mkdir) => mkdir.byte_size(),
|
||||
Tmessage::RenameAt(renameat) => renameat.byte_size(),
|
||||
Tmessage::UnlinkAt(unlinkat) => unlinkat.byte_size(),
|
||||
};
|
||||
|
||||
// size + type + tag + message size
|
||||
|
@ -196,35 +196,35 @@ impl WireFormat for Tframe {
|
|||
ty.encode(writer)?;
|
||||
self.tag.encode(writer)?;
|
||||
|
||||
match self.msg {
|
||||
Tmessage::Version(ref version) => version.encode(writer),
|
||||
Tmessage::Flush(ref flush) => flush.encode(writer),
|
||||
Tmessage::Walk(ref walk) => walk.encode(writer),
|
||||
Tmessage::Read(ref read) => read.encode(writer),
|
||||
Tmessage::Write(ref write) => write.encode(writer),
|
||||
Tmessage::Clunk(ref clunk) => clunk.encode(writer),
|
||||
Tmessage::Remove(ref remove) => remove.encode(writer),
|
||||
Tmessage::Attach(ref attach) => attach.encode(writer),
|
||||
Tmessage::Auth(ref auth) => auth.encode(writer),
|
||||
Tmessage::Statfs(ref statfs) => statfs.encode(writer),
|
||||
Tmessage::Lopen(ref lopen) => lopen.encode(writer),
|
||||
Tmessage::Lcreate(ref lcreate) => lcreate.encode(writer),
|
||||
Tmessage::Symlink(ref symlink) => symlink.encode(writer),
|
||||
Tmessage::Mknod(ref mknod) => mknod.encode(writer),
|
||||
Tmessage::Rename(ref rename) => rename.encode(writer),
|
||||
Tmessage::Readlink(ref readlink) => readlink.encode(writer),
|
||||
Tmessage::GetAttr(ref getattr) => getattr.encode(writer),
|
||||
Tmessage::SetAttr(ref setattr) => setattr.encode(writer),
|
||||
Tmessage::XattrWalk(ref xattrwalk) => xattrwalk.encode(writer),
|
||||
Tmessage::XattrCreate(ref xattrcreate) => xattrcreate.encode(writer),
|
||||
Tmessage::Readdir(ref readdir) => readdir.encode(writer),
|
||||
Tmessage::Fsync(ref fsync) => fsync.encode(writer),
|
||||
Tmessage::Lock(ref lock) => lock.encode(writer),
|
||||
Tmessage::GetLock(ref getlock) => getlock.encode(writer),
|
||||
Tmessage::Link(ref link) => link.encode(writer),
|
||||
Tmessage::Mkdir(ref mkdir) => mkdir.encode(writer),
|
||||
Tmessage::RenameAt(ref renameat) => renameat.encode(writer),
|
||||
Tmessage::UnlinkAt(ref unlinkat) => unlinkat.encode(writer),
|
||||
match &self.msg {
|
||||
Tmessage::Version(version) => version.encode(writer),
|
||||
Tmessage::Flush(flush) => flush.encode(writer),
|
||||
Tmessage::Walk(walk) => walk.encode(writer),
|
||||
Tmessage::Read(read) => read.encode(writer),
|
||||
Tmessage::Write(write) => write.encode(writer),
|
||||
Tmessage::Clunk(clunk) => clunk.encode(writer),
|
||||
Tmessage::Remove(remove) => remove.encode(writer),
|
||||
Tmessage::Attach(attach) => attach.encode(writer),
|
||||
Tmessage::Auth(auth) => auth.encode(writer),
|
||||
Tmessage::Statfs(statfs) => statfs.encode(writer),
|
||||
Tmessage::Lopen(lopen) => lopen.encode(writer),
|
||||
Tmessage::Lcreate(lcreate) => lcreate.encode(writer),
|
||||
Tmessage::Symlink(symlink) => symlink.encode(writer),
|
||||
Tmessage::Mknod(mknod) => mknod.encode(writer),
|
||||
Tmessage::Rename(rename) => rename.encode(writer),
|
||||
Tmessage::Readlink(readlink) => readlink.encode(writer),
|
||||
Tmessage::GetAttr(getattr) => getattr.encode(writer),
|
||||
Tmessage::SetAttr(setattr) => setattr.encode(writer),
|
||||
Tmessage::XattrWalk(xattrwalk) => xattrwalk.encode(writer),
|
||||
Tmessage::XattrCreate(xattrcreate) => xattrcreate.encode(writer),
|
||||
Tmessage::Readdir(readdir) => readdir.encode(writer),
|
||||
Tmessage::Fsync(fsync) => fsync.encode(writer),
|
||||
Tmessage::Lock(lock) => lock.encode(writer),
|
||||
Tmessage::GetLock(getlock) => getlock.encode(writer),
|
||||
Tmessage::Link(link) => link.encode(writer),
|
||||
Tmessage::Mkdir(mkdir) => mkdir.encode(writer),
|
||||
Tmessage::RenameAt(renameat) => renameat.encode(writer),
|
||||
Tmessage::UnlinkAt(unlinkat) => unlinkat.encode(writer),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -538,36 +538,36 @@ pub struct Rframe {
|
|||
|
||||
impl WireFormat for Rframe {
|
||||
fn byte_size(&self) -> u32 {
|
||||
let msg_size = match self.msg {
|
||||
Rmessage::Version(ref version) => version.byte_size(),
|
||||
let msg_size = match &self.msg {
|
||||
Rmessage::Version(version) => version.byte_size(),
|
||||
Rmessage::Flush => 0,
|
||||
Rmessage::Walk(ref walk) => walk.byte_size(),
|
||||
Rmessage::Read(ref read) => read.byte_size(),
|
||||
Rmessage::Write(ref write) => write.byte_size(),
|
||||
Rmessage::Walk(walk) => walk.byte_size(),
|
||||
Rmessage::Read(read) => read.byte_size(),
|
||||
Rmessage::Write(write) => write.byte_size(),
|
||||
Rmessage::Clunk => 0,
|
||||
Rmessage::Remove => 0,
|
||||
Rmessage::Attach(ref attach) => attach.byte_size(),
|
||||
Rmessage::Auth(ref auth) => auth.byte_size(),
|
||||
Rmessage::Statfs(ref statfs) => statfs.byte_size(),
|
||||
Rmessage::Lopen(ref lopen) => lopen.byte_size(),
|
||||
Rmessage::Lcreate(ref lcreate) => lcreate.byte_size(),
|
||||
Rmessage::Symlink(ref symlink) => symlink.byte_size(),
|
||||
Rmessage::Mknod(ref mknod) => mknod.byte_size(),
|
||||
Rmessage::Attach(attach) => attach.byte_size(),
|
||||
Rmessage::Auth(auth) => auth.byte_size(),
|
||||
Rmessage::Statfs(statfs) => statfs.byte_size(),
|
||||
Rmessage::Lopen(lopen) => lopen.byte_size(),
|
||||
Rmessage::Lcreate(lcreate) => lcreate.byte_size(),
|
||||
Rmessage::Symlink(symlink) => symlink.byte_size(),
|
||||
Rmessage::Mknod(mknod) => mknod.byte_size(),
|
||||
Rmessage::Rename => 0,
|
||||
Rmessage::Readlink(ref readlink) => readlink.byte_size(),
|
||||
Rmessage::GetAttr(ref getattr) => getattr.byte_size(),
|
||||
Rmessage::Readlink(readlink) => readlink.byte_size(),
|
||||
Rmessage::GetAttr(getattr) => getattr.byte_size(),
|
||||
Rmessage::SetAttr => 0,
|
||||
Rmessage::XattrWalk(ref xattrwalk) => xattrwalk.byte_size(),
|
||||
Rmessage::XattrWalk(xattrwalk) => xattrwalk.byte_size(),
|
||||
Rmessage::XattrCreate => 0,
|
||||
Rmessage::Readdir(ref readdir) => readdir.byte_size(),
|
||||
Rmessage::Readdir(readdir) => readdir.byte_size(),
|
||||
Rmessage::Fsync => 0,
|
||||
Rmessage::Lock(ref lock) => lock.byte_size(),
|
||||
Rmessage::GetLock(ref getlock) => getlock.byte_size(),
|
||||
Rmessage::Lock(lock) => lock.byte_size(),
|
||||
Rmessage::GetLock(getlock) => getlock.byte_size(),
|
||||
Rmessage::Link => 0,
|
||||
Rmessage::Mkdir(ref mkdir) => mkdir.byte_size(),
|
||||
Rmessage::Mkdir(mkdir) => mkdir.byte_size(),
|
||||
Rmessage::RenameAt => 0,
|
||||
Rmessage::UnlinkAt => 0,
|
||||
Rmessage::Lerror(ref lerror) => lerror.byte_size(),
|
||||
Rmessage::Lerror(lerror) => lerror.byte_size(),
|
||||
};
|
||||
|
||||
// size + type + tag + message size
|
||||
|
@ -612,36 +612,36 @@ impl WireFormat for Rframe {
|
|||
ty.encode(writer)?;
|
||||
self.tag.encode(writer)?;
|
||||
|
||||
match self.msg {
|
||||
Rmessage::Version(ref version) => version.encode(writer),
|
||||
match &self.msg {
|
||||
Rmessage::Version(version) => version.encode(writer),
|
||||
Rmessage::Flush => Ok(()),
|
||||
Rmessage::Walk(ref walk) => walk.encode(writer),
|
||||
Rmessage::Read(ref read) => read.encode(writer),
|
||||
Rmessage::Write(ref write) => write.encode(writer),
|
||||
Rmessage::Walk(walk) => walk.encode(writer),
|
||||
Rmessage::Read(read) => read.encode(writer),
|
||||
Rmessage::Write(write) => write.encode(writer),
|
||||
Rmessage::Clunk => Ok(()),
|
||||
Rmessage::Remove => Ok(()),
|
||||
Rmessage::Attach(ref attach) => attach.encode(writer),
|
||||
Rmessage::Auth(ref auth) => auth.encode(writer),
|
||||
Rmessage::Statfs(ref statfs) => statfs.encode(writer),
|
||||
Rmessage::Lopen(ref lopen) => lopen.encode(writer),
|
||||
Rmessage::Lcreate(ref lcreate) => lcreate.encode(writer),
|
||||
Rmessage::Symlink(ref symlink) => symlink.encode(writer),
|
||||
Rmessage::Mknod(ref mknod) => mknod.encode(writer),
|
||||
Rmessage::Attach(attach) => attach.encode(writer),
|
||||
Rmessage::Auth(auth) => auth.encode(writer),
|
||||
Rmessage::Statfs(statfs) => statfs.encode(writer),
|
||||
Rmessage::Lopen(lopen) => lopen.encode(writer),
|
||||
Rmessage::Lcreate(lcreate) => lcreate.encode(writer),
|
||||
Rmessage::Symlink(symlink) => symlink.encode(writer),
|
||||
Rmessage::Mknod(mknod) => mknod.encode(writer),
|
||||
Rmessage::Rename => Ok(()),
|
||||
Rmessage::Readlink(ref readlink) => readlink.encode(writer),
|
||||
Rmessage::GetAttr(ref getattr) => getattr.encode(writer),
|
||||
Rmessage::Readlink(readlink) => readlink.encode(writer),
|
||||
Rmessage::GetAttr(getattr) => getattr.encode(writer),
|
||||
Rmessage::SetAttr => Ok(()),
|
||||
Rmessage::XattrWalk(ref xattrwalk) => xattrwalk.encode(writer),
|
||||
Rmessage::XattrWalk(xattrwalk) => xattrwalk.encode(writer),
|
||||
Rmessage::XattrCreate => Ok(()),
|
||||
Rmessage::Readdir(ref readdir) => readdir.encode(writer),
|
||||
Rmessage::Readdir(readdir) => readdir.encode(writer),
|
||||
Rmessage::Fsync => Ok(()),
|
||||
Rmessage::Lock(ref lock) => lock.encode(writer),
|
||||
Rmessage::GetLock(ref getlock) => getlock.encode(writer),
|
||||
Rmessage::Lock(lock) => lock.encode(writer),
|
||||
Rmessage::GetLock(getlock) => getlock.encode(writer),
|
||||
Rmessage::Link => Ok(()),
|
||||
Rmessage::Mkdir(ref mkdir) => mkdir.encode(writer),
|
||||
Rmessage::Mkdir(mkdir) => mkdir.encode(writer),
|
||||
Rmessage::RenameAt => Ok(()),
|
||||
Rmessage::UnlinkAt => Ok(()),
|
||||
Rmessage::Lerror(ref lerror) => lerror.encode(writer),
|
||||
Rmessage::Lerror(lerror) => lerror.encode(writer),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -228,35 +228,35 @@ impl Server {
|
|||
println!("{:?}", &request);
|
||||
}
|
||||
|
||||
let rmsg = match request.msg {
|
||||
Tmessage::Version(ref version) => self.version(version),
|
||||
Tmessage::Flush(ref flush) => self.flush(flush),
|
||||
Tmessage::Walk(ref walk) => self.walk(walk),
|
||||
Tmessage::Read(ref read) => self.read(read),
|
||||
Tmessage::Write(ref write) => self.write(write),
|
||||
Tmessage::Clunk(ref clunk) => self.clunk(clunk),
|
||||
Tmessage::Remove(ref remove) => self.remove(remove),
|
||||
Tmessage::Attach(ref attach) => self.attach(attach),
|
||||
Tmessage::Auth(ref auth) => self.auth(auth),
|
||||
Tmessage::Statfs(ref statfs) => self.statfs(statfs),
|
||||
Tmessage::Lopen(ref lopen) => self.lopen(lopen),
|
||||
Tmessage::Lcreate(ref lcreate) => self.lcreate(lcreate),
|
||||
Tmessage::Symlink(ref symlink) => self.symlink(symlink),
|
||||
Tmessage::Mknod(ref mknod) => self.mknod(mknod),
|
||||
Tmessage::Rename(ref rename) => self.rename(rename),
|
||||
Tmessage::Readlink(ref readlink) => self.readlink(readlink),
|
||||
Tmessage::GetAttr(ref get_attr) => self.get_attr(get_attr),
|
||||
Tmessage::SetAttr(ref set_attr) => self.set_attr(set_attr),
|
||||
Tmessage::XattrWalk(ref xattr_walk) => self.xattr_walk(xattr_walk),
|
||||
Tmessage::XattrCreate(ref xattr_create) => self.xattr_create(xattr_create),
|
||||
Tmessage::Readdir(ref readdir) => self.readdir(readdir),
|
||||
Tmessage::Fsync(ref fsync) => self.fsync(fsync),
|
||||
Tmessage::Lock(ref lock) => self.lock(lock),
|
||||
Tmessage::GetLock(ref get_lock) => self.get_lock(get_lock),
|
||||
Tmessage::Link(ref link) => self.link(link),
|
||||
Tmessage::Mkdir(ref mkdir) => self.mkdir(mkdir),
|
||||
Tmessage::RenameAt(ref rename_at) => self.rename_at(rename_at),
|
||||
Tmessage::UnlinkAt(ref unlink_at) => self.unlink_at(unlink_at),
|
||||
let rmsg = match &request.msg {
|
||||
Tmessage::Version(version) => self.version(version),
|
||||
Tmessage::Flush(flush) => self.flush(flush),
|
||||
Tmessage::Walk(walk) => self.walk(walk),
|
||||
Tmessage::Read(read) => self.read(read),
|
||||
Tmessage::Write(write) => self.write(write),
|
||||
Tmessage::Clunk(clunk) => self.clunk(clunk),
|
||||
Tmessage::Remove(remove) => self.remove(remove),
|
||||
Tmessage::Attach(attach) => self.attach(attach),
|
||||
Tmessage::Auth(auth) => self.auth(auth),
|
||||
Tmessage::Statfs(statfs) => self.statfs(statfs),
|
||||
Tmessage::Lopen(lopen) => self.lopen(lopen),
|
||||
Tmessage::Lcreate(lcreate) => self.lcreate(lcreate),
|
||||
Tmessage::Symlink(symlink) => self.symlink(symlink),
|
||||
Tmessage::Mknod(mknod) => self.mknod(mknod),
|
||||
Tmessage::Rename(rename) => self.rename(rename),
|
||||
Tmessage::Readlink(readlink) => self.readlink(readlink),
|
||||
Tmessage::GetAttr(get_attr) => self.get_attr(get_attr),
|
||||
Tmessage::SetAttr(set_attr) => self.set_attr(set_attr),
|
||||
Tmessage::XattrWalk(xattr_walk) => self.xattr_walk(xattr_walk),
|
||||
Tmessage::XattrCreate(xattr_create) => self.xattr_create(xattr_create),
|
||||
Tmessage::Readdir(readdir) => self.readdir(readdir),
|
||||
Tmessage::Fsync(fsync) => self.fsync(fsync),
|
||||
Tmessage::Lock(lock) => self.lock(lock),
|
||||
Tmessage::GetLock(get_lock) => self.get_lock(get_lock),
|
||||
Tmessage::Link(link) => self.link(link),
|
||||
Tmessage::Mkdir(mkdir) => self.mkdir(mkdir),
|
||||
Tmessage::RenameAt(rename_at) => self.rename_at(rename_at),
|
||||
Tmessage::UnlinkAt(unlink_at) => self.unlink_at(unlink_at),
|
||||
};
|
||||
|
||||
// Errors while handling requests are never fatal.
|
||||
|
|
|
@ -65,8 +65,8 @@ fn p9_wire_format_inner(input: DeriveInput) -> TokenStream {
|
|||
|
||||
// Generate code that recursively calls byte_size on every field in the struct.
|
||||
fn byte_size_sum(data: &Data) -> TokenStream {
|
||||
if let Data::Struct(ref data) = *data {
|
||||
if let Fields::Named(ref fields) = data.fields {
|
||||
if let Data::Struct(data) = data {
|
||||
if let Fields::Named(fields) = &data.fields {
|
||||
let fields = fields.named.iter().map(|f| {
|
||||
let field = &f.ident;
|
||||
let span = field.span();
|
||||
|
@ -88,8 +88,8 @@ fn byte_size_sum(data: &Data) -> TokenStream {
|
|||
|
||||
// Generate code that recursively calls encode on every field in the struct.
|
||||
fn encode_wire_format(data: &Data) -> TokenStream {
|
||||
if let Data::Struct(ref data) = *data {
|
||||
if let Fields::Named(ref fields) = data.fields {
|
||||
if let Data::Struct(data) = data {
|
||||
if let Fields::Named(fields) = &data.fields {
|
||||
let fields = fields.named.iter().map(|f| {
|
||||
let field = &f.ident;
|
||||
let span = field.span();
|
||||
|
@ -113,8 +113,8 @@ fn encode_wire_format(data: &Data) -> TokenStream {
|
|||
|
||||
// Generate code that recursively calls decode on every field in the struct.
|
||||
fn decode_wire_format(data: &Data, container: &Ident) -> TokenStream {
|
||||
if let Data::Struct(ref data) = *data {
|
||||
if let Fields::Named(ref fields) = data.fields {
|
||||
if let Data::Struct(data) = data {
|
||||
if let Fields::Named(fields) = &data.fields {
|
||||
let values = fields.named.iter().map(|f| {
|
||||
let field = &f.ident;
|
||||
let span = field.span();
|
||||
|
|
|
@ -324,7 +324,7 @@ pub fn print_help(program_name: &str, required_arg: &str, args: &[Argument]) {
|
|||
println!("Argument{}:", if args.len() > 1 { "s" } else { "" });
|
||||
for arg in args {
|
||||
match arg.short {
|
||||
Some(ref s) => print!(" -{}, ", s),
|
||||
Some(s) => print!(" -{}, ", s),
|
||||
None => print!(" "),
|
||||
}
|
||||
if arg.long.is_empty() {
|
||||
|
|
10
src/linux.rs
10
src/linux.rs
|
@ -164,8 +164,8 @@ impl Display for Error {
|
|||
Disk(e) => write!(f, "failed to load disk image: {}", e),
|
||||
DiskImageLock(e) => write!(f, "failed to lock disk image: {}", e),
|
||||
DropCapabilities(e) => write!(f, "failed to drop process capabilities: {}", e),
|
||||
InputDeviceNew(ref e) => write!(f, "failed to set up input device: {}", e),
|
||||
InputEventsOpen(ref e) => write!(f, "failed to open event device: {}", e),
|
||||
InputDeviceNew(e) => write!(f, "failed to set up input device: {}", e),
|
||||
InputEventsOpen(e) => write!(f, "failed to open event device: {}", e),
|
||||
InvalidFdPath => write!(f, "failed parsing a /proc/self/fd/*"),
|
||||
InvalidWaylandPath => write!(f, "wayland socket path has no parent or file name"),
|
||||
IoJail(e) => write!(f, "{}", e),
|
||||
|
@ -1275,7 +1275,7 @@ fn run_control(
|
|||
|
||||
// Watch for low memory notifications and take memory back from the VM.
|
||||
let low_mem = File::open("/dev/chromeos-low-mem").ok();
|
||||
if let Some(ref low_mem) = low_mem {
|
||||
if let Some(low_mem) = &low_mem {
|
||||
poll_ctx
|
||||
.add(low_mem, Token::LowMemory)
|
||||
.map_err(Error::PollContextAdd)?;
|
||||
|
@ -1415,7 +1415,7 @@ fn run_control(
|
|||
}
|
||||
}
|
||||
Token::LowMemory => {
|
||||
if let Some(ref low_mem) = low_mem {
|
||||
if let Some(low_mem) = &low_mem {
|
||||
let old_balloon_memory = current_balloon_memory;
|
||||
current_balloon_memory = min(
|
||||
current_balloon_memory + balloon_memory_increment,
|
||||
|
@ -1453,7 +1453,7 @@ fn run_control(
|
|||
// Acknowledge the timer.
|
||||
lowmem_timer.wait().map_err(Error::TimerFd)?;
|
||||
|
||||
if let Some(ref low_mem) = low_mem {
|
||||
if let Some(low_mem) = &low_mem {
|
||||
// Start polling the lowmem device again.
|
||||
poll_ctx
|
||||
.add(low_mem, Token::LowMemory)
|
||||
|
|
|
@ -467,8 +467,8 @@ pub fn run_config(cfg: Config) -> Result<()> {
|
|||
|
||||
let jail = if cfg.sandbox {
|
||||
// An empty directory for jailed plugin pivot root.
|
||||
let root_path = match cfg.plugin_root {
|
||||
Some(ref dir) => Path::new(dir),
|
||||
let root_path = match &cfg.plugin_root {
|
||||
Some(dir) => dir,
|
||||
None => Path::new("/var/empty"),
|
||||
};
|
||||
|
||||
|
@ -599,7 +599,7 @@ pub fn run_config(cfg: Config) -> Result<()> {
|
|||
let plugin_socket_count = plugin.sockets().len();
|
||||
let events = {
|
||||
let poll_res = match dying_instant {
|
||||
Some(ref inst) => poll_ctx.wait_timeout(duration_to_die - inst.elapsed()),
|
||||
Some(inst) => poll_ctx.wait_timeout(duration_to_die - inst.elapsed()),
|
||||
None => poll_ctx.wait(),
|
||||
};
|
||||
match poll_res {
|
||||
|
|
|
@ -72,15 +72,15 @@ impl FakeClock {
|
|||
/// Drop any existing events registered to the same raw fd.
|
||||
pub fn add_event_fd(&mut self, deadline_ns: u64, fd: EventFd) {
|
||||
self.deadlines
|
||||
.retain(|&(_, ref old_fd)| fd.as_raw_fd() != old_fd.as_raw_fd());
|
||||
.retain(|(_, old_fd)| fd.as_raw_fd() != old_fd.as_raw_fd());
|
||||
self.deadlines.push((deadline_ns, fd));
|
||||
}
|
||||
|
||||
pub fn add_ns(&mut self, ns: u64) {
|
||||
self.ns_since_epoch += ns;
|
||||
let time = self.ns_since_epoch;
|
||||
self.deadlines.retain(|&(ns, ref fd)| {
|
||||
let expired = ns <= time;
|
||||
self.deadlines.retain(|(ns, fd)| {
|
||||
let expired = *ns <= time;
|
||||
if expired {
|
||||
fd.write(1).unwrap();
|
||||
}
|
||||
|
|
|
@ -93,8 +93,8 @@ pub struct GuestMemory {
|
|||
|
||||
impl AsRawFd for GuestMemory {
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
match self.memfd {
|
||||
Some(ref memfd) => memfd.as_raw_fd(),
|
||||
match &self.memfd {
|
||||
Some(memfd) => memfd.as_raw_fd(),
|
||||
None => panic!("GuestMemory is not backed by a memfd"),
|
||||
}
|
||||
}
|
||||
|
@ -165,8 +165,8 @@ impl GuestMemory {
|
|||
}
|
||||
}
|
||||
|
||||
let mapping = match memfd {
|
||||
Some(ref memfd) => MemoryMapping::from_fd_offset(memfd, range.1 as usize, offset),
|
||||
let mapping = match &memfd {
|
||||
Some(memfd) => MemoryMapping::from_fd_offset(memfd, range.1 as usize, offset),
|
||||
None => MemoryMapping::new(range.1 as usize),
|
||||
}
|
||||
.map_err(Error::MemoryMappingFailed)?;
|
||||
|
|
|
@ -414,7 +414,7 @@ pub fn log(pri: Priority, fac: Facility, file_name: &str, line: u32, args: fmt::
|
|||
|
||||
let mut state = lock!();
|
||||
let mut buf = [0u8; 1024];
|
||||
if let Some(ref socket) = state.socket {
|
||||
if let Some(socket) = &state.socket {
|
||||
let tm = get_localtime();
|
||||
let prifac = (pri as u8) | (fac as u8);
|
||||
let (res, len) = {
|
||||
|
@ -452,7 +452,7 @@ pub fn log(pri: Priority, fac: Facility, file_name: &str, line: u32, args: fmt::
|
|||
)
|
||||
};
|
||||
if res.is_ok() {
|
||||
if let Some(ref mut file) = state.file {
|
||||
if let Some(file) = &mut state.file {
|
||||
let _ = file.write_all(&buf[..len]);
|
||||
}
|
||||
if state.stderr {
|
||||
|
|
|
@ -66,13 +66,13 @@ impl TempDir {
|
|||
|
||||
/// Returns the path to the tempdir if it is currently valid
|
||||
pub fn as_path(&self) -> Option<&Path> {
|
||||
self.path.as_ref().map(|ref p| p.as_path())
|
||||
self.path.as_ref().map(PathBuf::as_path)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TempDir {
|
||||
fn drop(&mut self) {
|
||||
if let Some(ref p) = self.path {
|
||||
if let Some(p) = &self.path {
|
||||
// Nothing can be done here if this returns an error.
|
||||
let _ = fs::remove_dir_all(p);
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ impl FakeTimerFd {
|
|||
pub fn wait(&mut self) -> Result<u64> {
|
||||
loop {
|
||||
self.fd.read()?;
|
||||
if let Some(ref mut deadline_ns) = self.deadline_ns {
|
||||
if let Some(deadline_ns) = &mut self.deadline_ns {
|
||||
let mut guard = self.clock.lock();
|
||||
let now = guard.nanos();
|
||||
if now >= *deadline_ns {
|
||||
|
|
|
@ -340,10 +340,10 @@ mod tests {
|
|||
}
|
||||
|
||||
fn assert_ok_or_known_failure<T>(res: Result<T>) {
|
||||
match res {
|
||||
match &res {
|
||||
// FakeNet won't respond to ioctl's
|
||||
Ok(_t) => {}
|
||||
Err(Error::IoctlError(ref ioe)) if ioe.raw_os_error().unwrap() == 25 => {}
|
||||
Err(Error::IoctlError(ioe)) if ioe.raw_os_error().unwrap() == 25 => {}
|
||||
Err(e) => panic!("Unexpected Error:\n{}", e),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue