Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed count_ones in favor of is_power_of_two #92

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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