mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-02 08:17:01 +00:00
Merge pull request #10839 from RuoqingHe/appease-clippy
dragonball: Appease clippy
This commit is contained in:
commit
e1b780492f
@ -166,15 +166,6 @@ impl Range {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for Range {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
match self.min.cmp(&other.min) {
|
||||
Ordering::Equal => Some(self.max.cmp(&other.max)),
|
||||
res => Some(res),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for Range {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
match self.min.cmp(&other.min) {
|
||||
@ -184,6 +175,12 @@ impl Ord for Range {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for Range {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
/// State of interval tree node.
|
||||
///
|
||||
/// Valid state transitions:
|
||||
@ -424,7 +421,7 @@ impl<T> Node<T> {
|
||||
let l = height(&self.0.left);
|
||||
let r = height(&self.0.right);
|
||||
match (l as i32) - (r as i32) {
|
||||
1 | 0 | -1 => self,
|
||||
-1..=1 => self,
|
||||
2 => self.rotate_left_successor(),
|
||||
-2 => self.rotate_right_successor(),
|
||||
_ => unreachable!(),
|
||||
|
@ -152,7 +152,7 @@ impl Ord for IoRange {
|
||||
|
||||
impl PartialOrd for IoRange {
|
||||
fn partial_cmp(&self, other: &IoRange) -> Option<Ordering> {
|
||||
self.base.partial_cmp(&other.base)
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ fn validate_and_configure_tap(tap: &Tap, vq_pairs: usize) -> VirtioResult<()> {
|
||||
TapError::MissingFlags(
|
||||
missing_flags
|
||||
.into_iter()
|
||||
.map(|flag| *flag)
|
||||
.copied()
|
||||
.collect::<Vec<&str>>()
|
||||
.join(", "),
|
||||
),
|
||||
@ -372,7 +372,7 @@ where
|
||||
let intr_evts = config.get_queue_interrupt_eventfds();
|
||||
assert_eq!(config.queues.len(), intr_evts.len());
|
||||
|
||||
let vq_pair = vec![
|
||||
let vq_pair = [
|
||||
&config.queues[2 * pair_index],
|
||||
&config.queues[2 * pair_index + 1],
|
||||
];
|
||||
|
@ -165,7 +165,7 @@ where
|
||||
if queue_idx < self.intr_evts.len() {
|
||||
if let Err(e) = self.intr_evts[queue_idx].read() {
|
||||
error!("{}: failed to read queue eventfd, {:?}", self.id, e);
|
||||
} else if let Err(e) = self.config.queues[queue_idx as usize].notify() {
|
||||
} else if let Err(e) = self.config.queues[queue_idx].notify() {
|
||||
error!("{}: failed to notify guest, {:?}", self.id, e);
|
||||
}
|
||||
} else {
|
||||
@ -249,7 +249,7 @@ impl VhostUserBlockDevice {
|
||||
master.set_protocol_features(protocol_featuers)?;
|
||||
|
||||
let config_len = mem::size_of::<VirtioBlockConfig>();
|
||||
let config_space: Vec<u8> = vec![0u8; config_len as usize];
|
||||
let config_space: Vec<u8> = vec![0u8; config_len];
|
||||
|
||||
let (_, mut config_space) = master
|
||||
.get_config(
|
||||
|
@ -229,8 +229,8 @@ impl Endpoint {
|
||||
})?;
|
||||
|
||||
regions.push(VhostUserMemoryRegionInfo {
|
||||
guest_phys_addr: guest_phys_addr.raw_value() as u64,
|
||||
memory_size: region.len() as u64,
|
||||
guest_phys_addr: guest_phys_addr.raw_value(),
|
||||
memory_size: region.len(),
|
||||
userspace_addr: userspace_addr as *const u8 as u64,
|
||||
mmap_offset: file_offset.start(),
|
||||
mmap_handle: file_offset.file().as_raw_fd(),
|
||||
@ -330,8 +330,8 @@ impl Endpoint {
|
||||
.map_err(|_| VirtioError::InvalidGuestAddress(guest_phys_addr))?;
|
||||
|
||||
regions.push(VhostUserMemoryRegionInfo {
|
||||
guest_phys_addr: guest_phys_addr.raw_value() as u64,
|
||||
memory_size: region.len() as u64,
|
||||
guest_phys_addr: guest_phys_addr.raw_value(),
|
||||
memory_size: region.len(),
|
||||
userspace_addr: userspace_addr as *const u8 as u64,
|
||||
mmap_offset: file_offset.start(),
|
||||
mmap_handle: file_offset.file().as_raw_fd(),
|
||||
@ -342,7 +342,7 @@ impl Endpoint {
|
||||
|
||||
// 9. setup vrings
|
||||
for queue_cfg in config.virtio_config.queues.iter() {
|
||||
master.set_vring_num(queue_cfg.index() as usize, queue_cfg.actual_size() as u16)?;
|
||||
master.set_vring_num(queue_cfg.index() as usize, queue_cfg.actual_size())?;
|
||||
info!(
|
||||
"{}: set_vring_num(idx: {}, size: {})",
|
||||
self.name,
|
||||
|
@ -55,9 +55,9 @@ impl VsockStream for HybridStream {
|
||||
let mut flag = unsafe { libc::fcntl(fd, libc::F_GETFL) };
|
||||
|
||||
if nonblocking {
|
||||
flag = flag | libc::O_NONBLOCK;
|
||||
flag |= libc::O_NONBLOCK;
|
||||
} else {
|
||||
flag = flag & !libc::O_NONBLOCK;
|
||||
flag |= !libc::O_NONBLOCK;
|
||||
}
|
||||
|
||||
let ret = unsafe { libc::fcntl(fd, libc::F_SETFL, flag) };
|
||||
|
Loading…
Reference in New Issue
Block a user