Skip to content

Commit b1f0e80

Browse files
committed
virtio/vsock: Fix clippy warnings
Signed-off-by: Tyler Fanelli <[email protected]>
1 parent 2e5d828 commit b1f0e80

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/devices/src/virtio/vsock/device.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ pub(crate) const EVQ_INDEX: usize = 2;
3333
/// - VIRTIO_F_VERSION_1: the device conforms to at least version 1.0 of the VirtIO spec.
3434
/// - VIRTIO_F_IN_ORDER: the device returns used buffers in the same order that the driver makes
3535
/// them available.
36-
pub(crate) const AVAIL_FEATURES: u64 = 1 << uapi::VIRTIO_F_VERSION_1 as u64
37-
| 1 << uapi::VIRTIO_F_IN_ORDER as u64
38-
| 1 << uapi::VIRTIO_VSOCK_F_DGRAM;
36+
pub(crate) const AVAIL_FEATURES: u64 = (1 << uapi::VIRTIO_F_VERSION_1 as u64)
37+
| (1 << uapi::VIRTIO_F_IN_ORDER as u64)
38+
| (1 << uapi::VIRTIO_VSOCK_F_DGRAM);
3939

4040
pub struct Vsock {
4141
cid: u64,

src/devices/src/virtio/vsock/muxer.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ impl VsockMuxer {
273273
match req._type {
274274
defs::SOCK_STREAM => {
275275
debug!("vsock: proxy create stream");
276-
let id = (req.peer_port as u64) << 32 | defs::TSI_PROXY_PORT as u64;
276+
let id = ((req.peer_port as u64) << 32) | (defs::TSI_PROXY_PORT as u64);
277277
match TcpProxy::new(
278278
id,
279279
self.cid,
@@ -295,7 +295,7 @@ impl VsockMuxer {
295295
}
296296
defs::SOCK_DGRAM => {
297297
debug!("vsock: proxy create dgram");
298-
let id = (req.peer_port as u64) << 32 | defs::TSI_PROXY_PORT as u64;
298+
let id = ((req.peer_port as u64) << 32) | (defs::TSI_PROXY_PORT as u64);
299299
match UdpProxy::new(
300300
id,
301301
self.cid,
@@ -321,7 +321,7 @@ impl VsockMuxer {
321321
fn process_connect(&self, pkt: &VsockPacket) {
322322
debug!("vsock: proxy connect request");
323323
if let Some(req) = pkt.read_connect_req() {
324-
let id = (req.peer_port as u64) << 32 | defs::TSI_PROXY_PORT as u64;
324+
let id = ((req.peer_port as u64) << 32) | (defs::TSI_PROXY_PORT as u64);
325325
debug!("vsock: proxy connect request: id={}", id);
326326
let update = self
327327
.proxy_map
@@ -339,7 +339,7 @@ impl VsockMuxer {
339339
fn process_getname(&self, pkt: &VsockPacket) {
340340
debug!("vsock: new getname request");
341341
if let Some(req) = pkt.read_getname_req() {
342-
let id = (req.peer_port as u64) << 32 | (req.local_port as u64);
342+
let id = ((req.peer_port as u64) << 32) | (req.local_port as u64);
343343
debug!(
344344
"vsock: new getname request: id={}, peer_port={}, local_port={}",
345345
id, req.peer_port, req.local_port
@@ -354,7 +354,7 @@ impl VsockMuxer {
354354
fn process_sendto_addr(&self, pkt: &VsockPacket) {
355355
debug!("vsock: new DGRAM sendto addr: src={}", pkt.src_port());
356356
if let Some(req) = pkt.read_sendto_addr() {
357-
let id = (req.peer_port as u64) << 32 | defs::TSI_PROXY_PORT as u64;
357+
let id = ((req.peer_port as u64) << 32) | (defs::TSI_PROXY_PORT as u64);
358358
debug!("vsock: new DGRAM sendto addr: id={}", id);
359359
let update = self
360360
.proxy_map
@@ -370,7 +370,7 @@ impl VsockMuxer {
370370
}
371371

372372
fn process_sendto_data(&self, pkt: &VsockPacket) {
373-
let id = (pkt.src_port() as u64) << 32 | defs::TSI_PROXY_PORT as u64;
373+
let id = ((pkt.src_port() as u64) << 32) | (defs::TSI_PROXY_PORT as u64);
374374
debug!("vsock: DGRAM sendto data: id={} src={}", id, pkt.src_port());
375375
if let Some(proxy) = self.proxy_map.read().unwrap().get(&id) {
376376
proxy.lock().unwrap().sendto_data(pkt);
@@ -380,7 +380,7 @@ impl VsockMuxer {
380380
fn process_listen_request(&self, pkt: &VsockPacket) {
381381
debug!("vsock: DGRAM listen request: src={}", pkt.src_port());
382382
if let Some(req) = pkt.read_listen_req() {
383-
let id = (req.peer_port as u64) << 32 | defs::TSI_PROXY_PORT as u64;
383+
let id = ((req.peer_port as u64) << 32) | (defs::TSI_PROXY_PORT as u64);
384384
debug!("vsock: DGRAM listen request: id={}", id);
385385
let update = self
386386
.proxy_map
@@ -398,7 +398,7 @@ impl VsockMuxer {
398398
fn process_accept_request(&self, pkt: &VsockPacket) {
399399
debug!("vsock: DGRAM accept request: src={}", pkt.src_port());
400400
if let Some(req) = pkt.read_accept_req() {
401-
let id = (req.peer_port as u64) << 32 | defs::TSI_PROXY_PORT as u64;
401+
let id = ((req.peer_port as u64) << 32) | (defs::TSI_PROXY_PORT as u64);
402402
debug!("vsock: DGRAM accept request: id={}", id);
403403
let update = self
404404
.proxy_map
@@ -416,7 +416,7 @@ impl VsockMuxer {
416416
fn process_proxy_release(&self, pkt: &VsockPacket) {
417417
debug!("vsock: DGRAM release request: src={}", pkt.src_port());
418418
if let Some(req) = pkt.read_release_req() {
419-
let id = (req.peer_port as u64) << 32 | req.local_port as u64;
419+
let id = ((req.peer_port as u64) << 32) | (req.local_port as u64);
420420
debug!(
421421
"vsock: DGRAM release request: id={} local_port={} peer_port={}",
422422
id, req.local_port, req.peer_port
@@ -444,7 +444,7 @@ impl VsockMuxer {
444444

445445
fn process_dgram_rw(&self, pkt: &VsockPacket) {
446446
debug!("vsock: DGRAM OP_RW");
447-
let id = (pkt.src_port() as u64) << 32 | defs::TSI_PROXY_PORT as u64;
447+
let id = ((pkt.src_port() as u64) << 32) | (defs::TSI_PROXY_PORT as u64);
448448

449449
if let Some(proxy_lock) = self.proxy_map.read().unwrap().get(&id) {
450450
debug!("vsock: DGRAM allowing OP_RW for {}", pkt.src_port());
@@ -494,7 +494,7 @@ impl VsockMuxer {
494494

495495
fn process_op_request(&mut self, pkt: &VsockPacket) {
496496
debug!("vsock: OP_REQUEST");
497-
let id: u64 = (pkt.src_port() as u64) << 32 | pkt.dst_port() as u64;
497+
let id: u64 = ((pkt.src_port() as u64) << 32) | (pkt.dst_port() as u64);
498498
let mut proxy_map = self.proxy_map.write().unwrap();
499499

500500
if let Some(proxy) = proxy_map.get(&id) {
@@ -540,7 +540,7 @@ impl VsockMuxer {
540540

541541
fn process_op_response(&self, pkt: &VsockPacket) {
542542
debug!("vsock: OP_RESPONSE");
543-
let id: u64 = (pkt.src_port() as u64) << 32 | pkt.dst_port() as u64;
543+
let id: u64 = ((pkt.src_port() as u64) << 32) | (pkt.dst_port() as u64);
544544
let update = self
545545
.proxy_map
546546
.read()
@@ -565,15 +565,15 @@ impl VsockMuxer {
565565

566566
fn process_op_shutdown(&self, pkt: &VsockPacket) {
567567
debug!("vsock: OP_SHUTDOWN");
568-
let id: u64 = (pkt.src_port() as u64) << 32 | pkt.dst_port() as u64;
568+
let id: u64 = ((pkt.src_port() as u64) << 32) | (pkt.dst_port() as u64);
569569
if let Some(proxy) = self.proxy_map.read().unwrap().get(&id) {
570570
proxy.lock().unwrap().shutdown(pkt);
571571
}
572572
}
573573

574574
fn process_op_credit_update(&self, pkt: &VsockPacket) {
575575
debug!("vsock: OP_CREDIT_UPDATE");
576-
let id: u64 = (pkt.src_port() as u64) << 32 | pkt.dst_port() as u64;
576+
let id: u64 = ((pkt.src_port() as u64) << 32) | (pkt.dst_port() as u64);
577577
let update = self
578578
.proxy_map
579579
.read()
@@ -587,7 +587,7 @@ impl VsockMuxer {
587587

588588
fn process_stream_rw(&self, pkt: &VsockPacket) {
589589
debug!("vsock: OP_RW");
590-
let id: u64 = (pkt.src_port() as u64) << 32 | pkt.dst_port() as u64;
590+
let id: u64 = ((pkt.src_port() as u64) << 32) | (pkt.dst_port() as u64);
591591
if let Some(proxy_lock) = self.proxy_map.read().unwrap().get(&id) {
592592
debug!(
593593
"vsock: allowing OP_RW: src={} dst={}",
@@ -625,7 +625,7 @@ impl VsockMuxer {
625625

626626
fn process_stream_rst(&self, pkt: &VsockPacket) {
627627
debug!("vsock: OP_RST");
628-
let id: u64 = (pkt.src_port() as u64) << 32 | pkt.dst_port() as u64;
628+
let id: u64 = ((pkt.src_port() as u64) << 32) | (pkt.dst_port() as u64);
629629
if let Some(proxy_lock) = self.proxy_map.read().unwrap().get(&id) {
630630
debug!(
631631
"vsock: allowing OP_RST: id={} src={} dst={}",

src/devices/src/virtio/vsock/muxer_thread.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl MuxerThread {
120120

121121
if let Some((peer_port, accept_fd, proxy_type)) = update.new_proxy {
122122
let local_port: u32 = thread_rng.gen_range(1024..u32::MAX);
123-
let new_id: u64 = (peer_port as u64) << 32 | local_port as u64;
123+
let new_id: u64 = ((peer_port as u64) << 32) | (local_port as u64);
124124
let new_proxy: Box<dyn Proxy> = match proxy_type {
125125
NewProxyType::Tcp => Box::new(TcpProxy::new_reverse(
126126
new_id,
@@ -171,7 +171,7 @@ impl MuxerThread {
171171
if !do_listen {
172172
continue;
173173
}
174-
let id = (*port as u64) << 32 | defs::TSI_PROXY_PORT as u64;
174+
let id = ((*port as u64) << 32) | (defs::TSI_PROXY_PORT as u64);
175175
let proxy = match UnixAcceptorProxy::new(id, path, *port) {
176176
Ok(proxy) => proxy,
177177
Err(e) => {

0 commit comments

Comments
 (0)