Skip to content

Commit

Permalink
Removed count_ones in favor of is_power_of_two
Browse files Browse the repository at this point in the history
  • Loading branch information
EduMenges authored and rafalh committed May 2, 2024
1 parent fba8854 commit ef362a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/boot_sector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl BiosParameterBlock {
}

fn validate_bytes_per_sector<E: IoError>(&self) -> Result<(), Error<E>> {
if self.bytes_per_sector.count_ones() != 1 {
if !self.bytes_per_sector.is_power_of_two() {
error!(
"invalid bytes_per_sector value in BPB: expected a power of two but got {}",
self.bytes_per_sector
Expand All @@ -143,7 +143,7 @@ impl BiosParameterBlock {
}

fn validate_sectors_per_cluster<E: IoError>(&self) -> Result<(), Error<E>> {
if self.sectors_per_cluster.count_ones() != 1 {
if !self.sectors_per_cluster.is_power_of_two() {
error!(
"invalid sectors_per_cluster value in BPB: expected a power of two but got {}",
self.sectors_per_cluster
Expand Down
4 changes: 2 additions & 2 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ impl FormatVolumeOptions {
#[must_use]
pub fn bytes_per_cluster(mut self, bytes_per_cluster: u32) -> Self {
assert!(
bytes_per_cluster.count_ones() == 1 && bytes_per_cluster >= 512,
bytes_per_cluster.is_power_of_two() && bytes_per_cluster >= 512,
"Invalid bytes_per_cluster"
);
self.bytes_per_cluster = Some(bytes_per_cluster);
Expand Down Expand Up @@ -1011,7 +1011,7 @@ impl FormatVolumeOptions {
#[must_use]
pub fn bytes_per_sector(mut self, bytes_per_sector: u16) -> Self {
assert!(
bytes_per_sector.count_ones() == 1 && bytes_per_sector >= 512,
bytes_per_sector.is_power_of_two() && bytes_per_sector >= 512,
"Invalid bytes_per_sector"
);
self.bytes_per_sector = bytes_per_sector;
Expand Down

0 comments on commit ef362a1

Please sign in to comment.