mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
qcow: Fix wrong alignment calculation
With the existing code, `round_up(7, 2)` would generate `6` which is obviously wrong. Also, following what's done for 'round_down()', the fixed code does not handle 'alignment == 0' explicitly. Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
@@ -69,7 +69,7 @@ impl RawFile {
|
||||
|
||||
fn round_up(&self, offset: u64) -> u64 {
|
||||
let align: u64 = self.alignment.try_into().unwrap();
|
||||
((offset / (align + 1)) + 1) * align
|
||||
((offset + align - 1) / align) * align
|
||||
}
|
||||
|
||||
fn round_down(&self, offset: u64) -> u64 {
|
||||
|
||||
Reference in New Issue
Block a user