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:
Bo Chen 2022-09-16 13:45:56 -07:00 committed by Rob Bradford
parent 134e555c42
commit 5f4a6b42c0

View File

@ -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 {