Skip to content

Commit

Permalink
Remove redundant check for sectors_per_cluster
Browse files Browse the repository at this point in the history
If sectors_per_cluster.count_ones() == 1 (previous check) and
sectors_per_cluster is u8 it is always at least 1 and at most 128.
  • Loading branch information
rafalh committed Apr 23, 2024
1 parent 46c15fc commit fba8854
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/boot_sector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,6 @@ impl BiosParameterBlock {
);
return Err(Error::CorruptedFileSystem);
}
if self.sectors_per_cluster < 1 || self.sectors_per_cluster > 128 {
error!(
"invalid sectors_per_cluster value in BPB: expected value in range [1, 128] but got {}",
self.sectors_per_cluster
);
return Err(Error::CorruptedFileSystem);
}

// bytes per sector is u16, sectors per cluster is u8, so guaranteed no overflow in multiplication
let bytes_per_cluster = u32::from(self.bytes_per_sector) * u32::from(self.sectors_per_cluster);
Expand Down

0 comments on commit fba8854

Please sign in to comment.