vsock: fix clippy warnings

clippy complains of some minor issues, probably because the
new version has been improved. Let's fix them.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This commit is contained in:
Stefano Garzarella 2022-09-26 18:54:47 +02:00
parent e20698695b
commit 69882e1dfc
7 changed files with 10 additions and 11 deletions

View File

@ -398,17 +398,16 @@ pub mod tests {
let virt_queue = MockSplitQueue::new(&mem, 16);
let mut next_addr = virt_queue.desc_table().total_size() + 0x100;
let mut flags = 0;
let mut head_flags;
if write_only {
flags |= VIRTQ_DESC_F_WRITE;
}
if data_chain_len > 0 {
head_flags = flags | VIRTQ_DESC_F_NEXT
let mut head_flags = if data_chain_len > 0 {
flags | VIRTQ_DESC_F_NEXT
} else {
head_flags = flags;
}
flags
};
// vsock packet header
// let header = vec![0 as u8; head_params.head_len];

View File

@ -1,4 +1,4 @@
#[derive(Clone, Copy, PartialEq, Debug)]
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
pub enum RxOps {
/// VSOCK_OP_REQUEST
Request = 0,

View File

@ -1,6 +1,6 @@
use super::rxops::RxOps;
#[derive(Debug, PartialEq)]
#[derive(Debug, Eq, PartialEq)]
pub struct RxQueue {
/// Bitmap of rx operations.
queue: u8,

View File

@ -141,7 +141,7 @@ impl VsockThreadBackend {
if !self.conn_map.contains_key(&key) {
// The packet contains a new connection request
if pkt.op() == VSOCK_OP_REQUEST {
self.handle_new_guest_conn(&pkt);
self.handle_new_guest_conn(pkt);
} else {
// TODO: send back RST
}

View File

@ -172,7 +172,7 @@ mod tests {
// flush data of CONN_TX_BUF_SIZE amount
let res_push = loc_tx_buf.push(&data);
assert_eq!(res_push.is_ok(), true);
assert!(res_push.is_ok());
let res_flush = loc_tx_buf.flush_to(&mut cmp_vec);
if let Ok(n) = res_flush {
assert_eq!(loc_tx_buf.head, Wrapping(n as u32));

View File

@ -249,7 +249,7 @@ impl VhostUserVsockThread {
} else {
// Previously connected connection
let key = self.thread_backend.listener_map.get(&fd).unwrap();
let vsock_conn = self.thread_backend.conn_map.get_mut(&key).unwrap();
let vsock_conn = self.thread_backend.conn_map.get_mut(key).unwrap();
if evset == epoll::Events::EPOLLOUT {
// Flush any remaining data from the tx buffer

View File

@ -322,7 +322,7 @@ impl<S: AsRawFd + Read + Write> VsockConnection<S> {
/// Get max number of bytes we can send to peer without overflowing
/// the peer's buffer.
fn peer_avail_credit(&self) -> usize {
(Wrapping(self.peer_buf_alloc as u32) - (self.rx_cnt - self.peer_fwd_cnt)).0 as usize
(Wrapping(self.peer_buf_alloc) - (self.rx_cnt - self.peer_fwd_cnt)).0 as usize
}
/// Check if we need a credit update from the peer before sending