mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-21 21:25:19 +00:00
misc: Remove manual implementation of is_power_of_two
As clippy of rust-toolchain version 1.83.0-beta.1 suggests, remove manual implementation of `is_power_of_two` to improve readability. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
parent
6164aa0885
commit
b41daddce1
@ -24,7 +24,7 @@ impl QcowRawFile {
|
|||||||
/// Creates a `QcowRawFile` from the given `File`, `None` is returned if `cluster_size` is not
|
/// Creates a `QcowRawFile` from the given `File`, `None` is returned if `cluster_size` is not
|
||||||
/// a power of two.
|
/// a power of two.
|
||||||
pub fn from(file: RawFile, cluster_size: u64) -> Option<Self> {
|
pub fn from(file: RawFile, cluster_size: u64) -> Option<Self> {
|
||||||
if cluster_size.count_ones() != 1 {
|
if !cluster_size.is_power_of_two() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(QcowRawFile {
|
Some(QcowRawFile {
|
||||||
|
@ -734,7 +734,7 @@ impl PciConfiguration {
|
|||||||
return Err(Error::BarInUse(bar_idx));
|
return Err(Error::BarInUse(bar_idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.size.count_ones() != 1 {
|
if !config.size.is_power_of_two() {
|
||||||
return Err(Error::BarSizeInvalid(config.size));
|
return Err(Error::BarSizeInvalid(config.size));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -806,7 +806,7 @@ impl PciConfiguration {
|
|||||||
return Err(Error::RomBarInUse(bar_idx));
|
return Err(Error::RomBarInUse(bar_idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.size.count_ones() != 1 {
|
if !config.size.is_power_of_two() {
|
||||||
return Err(Error::RomBarSizeInvalid(config.size));
|
return Err(Error::RomBarSizeInvalid(config.size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ pub mod testing {
|
|||||||
// We try to make sure things are aligned properly :-s
|
// We try to make sure things are aligned properly :-s
|
||||||
pub fn new(start: GuestAddress, mem: &'a GuestMemoryMmap, qsize: u16) -> Self {
|
pub fn new(start: GuestAddress, mem: &'a GuestMemoryMmap, qsize: u16) -> Self {
|
||||||
// power of 2?
|
// power of 2?
|
||||||
assert!(qsize > 0 && qsize & (qsize - 1) == 0);
|
assert!(qsize.is_power_of_two());
|
||||||
|
|
||||||
let mut dtable = Vec::with_capacity(qsize as usize);
|
let mut dtable = Vec::with_capacity(qsize as usize);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user