From a85d480a76e7cedded4ac6b4e4922ff416df73df Mon Sep 17 00:00:00 2001 From: Tyler Fanelli Date: Mon, 24 Feb 2025 19:47:16 -0500 Subject: [PATCH] virtio/vsock: Fix clippy warnings Signed-off-by: Tyler Fanelli --- src/devices/src/virtio/vsock/device.rs | 6 ++-- src/devices/src/virtio/vsock/muxer.rs | 32 ++++++++++---------- src/devices/src/virtio/vsock/muxer_thread.rs | 4 +-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/devices/src/virtio/vsock/device.rs b/src/devices/src/virtio/vsock/device.rs index 01df1317..de0ee3ba 100644 --- a/src/devices/src/virtio/vsock/device.rs +++ b/src/devices/src/virtio/vsock/device.rs @@ -33,9 +33,9 @@ pub(crate) const EVQ_INDEX: usize = 2; /// - VIRTIO_F_VERSION_1: the device conforms to at least version 1.0 of the VirtIO spec. /// - VIRTIO_F_IN_ORDER: the device returns used buffers in the same order that the driver makes /// them available. -pub(crate) const AVAIL_FEATURES: u64 = 1 << uapi::VIRTIO_F_VERSION_1 as u64 - | 1 << uapi::VIRTIO_F_IN_ORDER as u64 - | 1 << uapi::VIRTIO_VSOCK_F_DGRAM; +pub(crate) const AVAIL_FEATURES: u64 = (1 << uapi::VIRTIO_F_VERSION_1 as u64) + | (1 << uapi::VIRTIO_F_IN_ORDER as u64) + | (1 << uapi::VIRTIO_VSOCK_F_DGRAM); pub struct Vsock { cid: u64, diff --git a/src/devices/src/virtio/vsock/muxer.rs b/src/devices/src/virtio/vsock/muxer.rs index 6d027dcd..fdecb1d8 100644 --- a/src/devices/src/virtio/vsock/muxer.rs +++ b/src/devices/src/virtio/vsock/muxer.rs @@ -273,7 +273,7 @@ impl VsockMuxer { match req._type { defs::SOCK_STREAM => { debug!("vsock: proxy create stream"); - let id = (req.peer_port as u64) << 32 | defs::TSI_PROXY_PORT as u64; + let id = ((req.peer_port as u64) << 32) | (defs::TSI_PROXY_PORT as u64); match TcpProxy::new( id, self.cid, @@ -295,7 +295,7 @@ impl VsockMuxer { } defs::SOCK_DGRAM => { debug!("vsock: proxy create dgram"); - let id = (req.peer_port as u64) << 32 | defs::TSI_PROXY_PORT as u64; + let id = ((req.peer_port as u64) << 32) | (defs::TSI_PROXY_PORT as u64); match UdpProxy::new( id, self.cid, @@ -321,7 +321,7 @@ impl VsockMuxer { fn process_connect(&self, pkt: &VsockPacket) { debug!("vsock: proxy connect request"); if let Some(req) = pkt.read_connect_req() { - let id = (req.peer_port as u64) << 32 | defs::TSI_PROXY_PORT as u64; + let id = ((req.peer_port as u64) << 32) | (defs::TSI_PROXY_PORT as u64); debug!("vsock: proxy connect request: id={}", id); let update = self .proxy_map @@ -339,7 +339,7 @@ impl VsockMuxer { fn process_getname(&self, pkt: &VsockPacket) { debug!("vsock: new getname request"); if let Some(req) = pkt.read_getname_req() { - let id = (req.peer_port as u64) << 32 | (req.local_port as u64); + let id = ((req.peer_port as u64) << 32) | (req.local_port as u64); debug!( "vsock: new getname request: id={}, peer_port={}, local_port={}", id, req.peer_port, req.local_port @@ -354,7 +354,7 @@ impl VsockMuxer { fn process_sendto_addr(&self, pkt: &VsockPacket) { debug!("vsock: new DGRAM sendto addr: src={}", pkt.src_port()); if let Some(req) = pkt.read_sendto_addr() { - let id = (req.peer_port as u64) << 32 | defs::TSI_PROXY_PORT as u64; + let id = ((req.peer_port as u64) << 32) | (defs::TSI_PROXY_PORT as u64); debug!("vsock: new DGRAM sendto addr: id={}", id); let update = self .proxy_map @@ -370,7 +370,7 @@ impl VsockMuxer { } fn process_sendto_data(&self, pkt: &VsockPacket) { - let id = (pkt.src_port() as u64) << 32 | defs::TSI_PROXY_PORT as u64; + let id = ((pkt.src_port() as u64) << 32) | (defs::TSI_PROXY_PORT as u64); debug!("vsock: DGRAM sendto data: id={} src={}", id, pkt.src_port()); if let Some(proxy) = self.proxy_map.read().unwrap().get(&id) { proxy.lock().unwrap().sendto_data(pkt); @@ -380,7 +380,7 @@ impl VsockMuxer { fn process_listen_request(&self, pkt: &VsockPacket) { debug!("vsock: DGRAM listen request: src={}", pkt.src_port()); if let Some(req) = pkt.read_listen_req() { - let id = (req.peer_port as u64) << 32 | defs::TSI_PROXY_PORT as u64; + let id = ((req.peer_port as u64) << 32) | (defs::TSI_PROXY_PORT as u64); debug!("vsock: DGRAM listen request: id={}", id); let update = self .proxy_map @@ -398,7 +398,7 @@ impl VsockMuxer { fn process_accept_request(&self, pkt: &VsockPacket) { debug!("vsock: DGRAM accept request: src={}", pkt.src_port()); if let Some(req) = pkt.read_accept_req() { - let id = (req.peer_port as u64) << 32 | defs::TSI_PROXY_PORT as u64; + let id = ((req.peer_port as u64) << 32) | (defs::TSI_PROXY_PORT as u64); debug!("vsock: DGRAM accept request: id={}", id); let update = self .proxy_map @@ -416,7 +416,7 @@ impl VsockMuxer { fn process_proxy_release(&self, pkt: &VsockPacket) { debug!("vsock: DGRAM release request: src={}", pkt.src_port()); if let Some(req) = pkt.read_release_req() { - let id = (req.peer_port as u64) << 32 | req.local_port as u64; + let id = ((req.peer_port as u64) << 32) | (req.local_port as u64); debug!( "vsock: DGRAM release request: id={} local_port={} peer_port={}", id, req.local_port, req.peer_port @@ -444,7 +444,7 @@ impl VsockMuxer { fn process_dgram_rw(&self, pkt: &VsockPacket) { debug!("vsock: DGRAM OP_RW"); - let id = (pkt.src_port() as u64) << 32 | defs::TSI_PROXY_PORT as u64; + let id = ((pkt.src_port() as u64) << 32) | (defs::TSI_PROXY_PORT as u64); if let Some(proxy_lock) = self.proxy_map.read().unwrap().get(&id) { debug!("vsock: DGRAM allowing OP_RW for {}", pkt.src_port()); @@ -494,7 +494,7 @@ impl VsockMuxer { fn process_op_request(&mut self, pkt: &VsockPacket) { debug!("vsock: OP_REQUEST"); - let id: u64 = (pkt.src_port() as u64) << 32 | pkt.dst_port() as u64; + let id: u64 = ((pkt.src_port() as u64) << 32) | (pkt.dst_port() as u64); let mut proxy_map = self.proxy_map.write().unwrap(); if let Some(proxy) = proxy_map.get(&id) { @@ -540,7 +540,7 @@ impl VsockMuxer { fn process_op_response(&self, pkt: &VsockPacket) { debug!("vsock: OP_RESPONSE"); - let id: u64 = (pkt.src_port() as u64) << 32 | pkt.dst_port() as u64; + let id: u64 = ((pkt.src_port() as u64) << 32) | (pkt.dst_port() as u64); let update = self .proxy_map .read() @@ -565,7 +565,7 @@ impl VsockMuxer { fn process_op_shutdown(&self, pkt: &VsockPacket) { debug!("vsock: OP_SHUTDOWN"); - let id: u64 = (pkt.src_port() as u64) << 32 | pkt.dst_port() as u64; + let id: u64 = ((pkt.src_port() as u64) << 32) | (pkt.dst_port() as u64); if let Some(proxy) = self.proxy_map.read().unwrap().get(&id) { proxy.lock().unwrap().shutdown(pkt); } @@ -573,7 +573,7 @@ impl VsockMuxer { fn process_op_credit_update(&self, pkt: &VsockPacket) { debug!("vsock: OP_CREDIT_UPDATE"); - let id: u64 = (pkt.src_port() as u64) << 32 | pkt.dst_port() as u64; + let id: u64 = ((pkt.src_port() as u64) << 32) | (pkt.dst_port() as u64); let update = self .proxy_map .read() @@ -587,7 +587,7 @@ impl VsockMuxer { fn process_stream_rw(&self, pkt: &VsockPacket) { debug!("vsock: OP_RW"); - let id: u64 = (pkt.src_port() as u64) << 32 | pkt.dst_port() as u64; + let id: u64 = ((pkt.src_port() as u64) << 32) | (pkt.dst_port() as u64); if let Some(proxy_lock) = self.proxy_map.read().unwrap().get(&id) { debug!( "vsock: allowing OP_RW: src={} dst={}", @@ -625,7 +625,7 @@ impl VsockMuxer { fn process_stream_rst(&self, pkt: &VsockPacket) { debug!("vsock: OP_RST"); - let id: u64 = (pkt.src_port() as u64) << 32 | pkt.dst_port() as u64; + let id: u64 = ((pkt.src_port() as u64) << 32) | (pkt.dst_port() as u64); if let Some(proxy_lock) = self.proxy_map.read().unwrap().get(&id) { debug!( "vsock: allowing OP_RST: id={} src={} dst={}", diff --git a/src/devices/src/virtio/vsock/muxer_thread.rs b/src/devices/src/virtio/vsock/muxer_thread.rs index a0aa8e40..f98f2d9a 100644 --- a/src/devices/src/virtio/vsock/muxer_thread.rs +++ b/src/devices/src/virtio/vsock/muxer_thread.rs @@ -120,7 +120,7 @@ impl MuxerThread { if let Some((peer_port, accept_fd, proxy_type)) = update.new_proxy { let local_port: u32 = thread_rng.gen_range(1024..u32::MAX); - let new_id: u64 = (peer_port as u64) << 32 | local_port as u64; + let new_id: u64 = ((peer_port as u64) << 32) | (local_port as u64); let new_proxy: Box = match proxy_type { NewProxyType::Tcp => Box::new(TcpProxy::new_reverse( new_id, @@ -171,7 +171,7 @@ impl MuxerThread { if !do_listen { continue; } - let id = (*port as u64) << 32 | defs::TSI_PROXY_PORT as u64; + let id = ((*port as u64) << 32) | (defs::TSI_PROXY_PORT as u64); let proxy = match UnixAcceptorProxy::new(id, path, *port) { Ok(proxy) => proxy, Err(e) => {