mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-05 21:15:45 +00:00
virtio-devices: Fix clippy::manual-range-contains issue
error: manual `Range::contains` implementation --> virtio-devices/src/transport/pci_device.rs:961:18 | 961 | o if ISR_CONFIG_BAR_OFFSET <= o && o < ISR_CONFIG_BAR_OFFSET + ISR_CONFIG_SIZE => { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `(ISR_CONFIG_BAR_OFFSET..ISR_CONFIG_BAR_OFFSET + ISR_CONFIG_SIZE).contains(&o)` | = note: `-D clippy::manual-range-contains` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains Signed-off-by: Akira Moroo <retrage01@gmail.com>
This commit is contained in:
parent
3a6df69d45
commit
17722ada51
@ -958,25 +958,25 @@ impl PciDevice for VirtioPciDevice {
|
|||||||
&mut self.queues,
|
&mut self.queues,
|
||||||
self.device.clone(),
|
self.device.clone(),
|
||||||
),
|
),
|
||||||
o if ISR_CONFIG_BAR_OFFSET <= o && o < ISR_CONFIG_BAR_OFFSET + ISR_CONFIG_SIZE => {
|
o if (ISR_CONFIG_BAR_OFFSET..ISR_CONFIG_BAR_OFFSET + ISR_CONFIG_SIZE).contains(&o) => {
|
||||||
if let Some(v) = data.get_mut(0) {
|
if let Some(v) = data.get_mut(0) {
|
||||||
// Reading this register resets it to 0.
|
// Reading this register resets it to 0.
|
||||||
*v = self.interrupt_status.swap(0, Ordering::AcqRel) as u8;
|
*v = self.interrupt_status.swap(0, Ordering::AcqRel) as u8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
o if DEVICE_CONFIG_BAR_OFFSET <= o
|
o if (DEVICE_CONFIG_BAR_OFFSET..DEVICE_CONFIG_BAR_OFFSET + DEVICE_CONFIG_SIZE)
|
||||||
&& o < DEVICE_CONFIG_BAR_OFFSET + DEVICE_CONFIG_SIZE =>
|
.contains(&o) =>
|
||||||
{
|
{
|
||||||
let device = self.device.lock().unwrap();
|
let device = self.device.lock().unwrap();
|
||||||
device.read_config(o - DEVICE_CONFIG_BAR_OFFSET, data);
|
device.read_config(o - DEVICE_CONFIG_BAR_OFFSET, data);
|
||||||
}
|
}
|
||||||
o if NOTIFICATION_BAR_OFFSET <= o
|
o if (NOTIFICATION_BAR_OFFSET..NOTIFICATION_BAR_OFFSET + NOTIFICATION_SIZE)
|
||||||
&& o < NOTIFICATION_BAR_OFFSET + NOTIFICATION_SIZE =>
|
.contains(&o) =>
|
||||||
{
|
{
|
||||||
// Handled with ioeventfds.
|
// Handled with ioeventfds.
|
||||||
error!("Unexpected read from notification BAR: offset = 0x{:x}", o);
|
error!("Unexpected read from notification BAR: offset = 0x{:x}", o);
|
||||||
}
|
}
|
||||||
o if MSIX_TABLE_BAR_OFFSET <= o && o < MSIX_TABLE_BAR_OFFSET + MSIX_TABLE_SIZE => {
|
o if (MSIX_TABLE_BAR_OFFSET..MSIX_TABLE_BAR_OFFSET + MSIX_TABLE_SIZE).contains(&o) => {
|
||||||
if let Some(msix_config) = &self.msix_config {
|
if let Some(msix_config) = &self.msix_config {
|
||||||
msix_config
|
msix_config
|
||||||
.lock()
|
.lock()
|
||||||
@ -984,7 +984,7 @@ impl PciDevice for VirtioPciDevice {
|
|||||||
.read_table(o - MSIX_TABLE_BAR_OFFSET, data);
|
.read_table(o - MSIX_TABLE_BAR_OFFSET, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
o if MSIX_PBA_BAR_OFFSET <= o && o < MSIX_PBA_BAR_OFFSET + MSIX_PBA_SIZE => {
|
o if (MSIX_PBA_BAR_OFFSET..MSIX_PBA_BAR_OFFSET + MSIX_PBA_SIZE).contains(&o) => {
|
||||||
if let Some(msix_config) = &self.msix_config {
|
if let Some(msix_config) = &self.msix_config {
|
||||||
msix_config
|
msix_config
|
||||||
.lock()
|
.lock()
|
||||||
@ -1004,25 +1004,25 @@ impl PciDevice for VirtioPciDevice {
|
|||||||
&mut self.queues,
|
&mut self.queues,
|
||||||
self.device.clone(),
|
self.device.clone(),
|
||||||
),
|
),
|
||||||
o if ISR_CONFIG_BAR_OFFSET <= o && o < ISR_CONFIG_BAR_OFFSET + ISR_CONFIG_SIZE => {
|
o if (ISR_CONFIG_BAR_OFFSET..ISR_CONFIG_BAR_OFFSET + ISR_CONFIG_SIZE).contains(&o) => {
|
||||||
if let Some(v) = data.get(0) {
|
if let Some(v) = data.get(0) {
|
||||||
self.interrupt_status
|
self.interrupt_status
|
||||||
.fetch_and(!(*v as usize), Ordering::AcqRel);
|
.fetch_and(!(*v as usize), Ordering::AcqRel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
o if DEVICE_CONFIG_BAR_OFFSET <= o
|
o if (DEVICE_CONFIG_BAR_OFFSET..DEVICE_CONFIG_BAR_OFFSET + DEVICE_CONFIG_SIZE)
|
||||||
&& o < DEVICE_CONFIG_BAR_OFFSET + DEVICE_CONFIG_SIZE =>
|
.contains(&o) =>
|
||||||
{
|
{
|
||||||
let mut device = self.device.lock().unwrap();
|
let mut device = self.device.lock().unwrap();
|
||||||
device.write_config(o - DEVICE_CONFIG_BAR_OFFSET, data);
|
device.write_config(o - DEVICE_CONFIG_BAR_OFFSET, data);
|
||||||
}
|
}
|
||||||
o if NOTIFICATION_BAR_OFFSET <= o
|
o if (NOTIFICATION_BAR_OFFSET..NOTIFICATION_BAR_OFFSET + NOTIFICATION_SIZE)
|
||||||
&& o < NOTIFICATION_BAR_OFFSET + NOTIFICATION_SIZE =>
|
.contains(&o) =>
|
||||||
{
|
{
|
||||||
// Handled with ioeventfds.
|
// Handled with ioeventfds.
|
||||||
error!("Unexpected write to notification BAR: offset = 0x{:x}", o);
|
error!("Unexpected write to notification BAR: offset = 0x{:x}", o);
|
||||||
}
|
}
|
||||||
o if MSIX_TABLE_BAR_OFFSET <= o && o < MSIX_TABLE_BAR_OFFSET + MSIX_TABLE_SIZE => {
|
o if (MSIX_TABLE_BAR_OFFSET..MSIX_TABLE_BAR_OFFSET + MSIX_TABLE_SIZE).contains(&o) => {
|
||||||
if let Some(msix_config) = &self.msix_config {
|
if let Some(msix_config) = &self.msix_config {
|
||||||
msix_config
|
msix_config
|
||||||
.lock()
|
.lock()
|
||||||
@ -1030,7 +1030,7 @@ impl PciDevice for VirtioPciDevice {
|
|||||||
.write_table(o - MSIX_TABLE_BAR_OFFSET, data);
|
.write_table(o - MSIX_TABLE_BAR_OFFSET, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
o if MSIX_PBA_BAR_OFFSET <= o && o < MSIX_PBA_BAR_OFFSET + MSIX_PBA_SIZE => {
|
o if (MSIX_PBA_BAR_OFFSET..MSIX_PBA_BAR_OFFSET + MSIX_PBA_SIZE).contains(&o) => {
|
||||||
if let Some(msix_config) = &self.msix_config {
|
if let Some(msix_config) = &self.msix_config {
|
||||||
msix_config
|
msix_config
|
||||||
.lock()
|
.lock()
|
||||||
|
Loading…
Reference in New Issue
Block a user