vhdx: Fix wrong alignment calculation

With the existing macro, `align!(7, 4)` would generate `16` which is
obviously wrong. Also, given it is a macro, the compiler catch the error
if the provided 'alignment' is '0'.

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen 2022-09-16 13:38:08 -07:00 committed by Rob Bradford
parent 18f1be0fac
commit 134e555c42

View File

@ -34,12 +34,7 @@ pub type Result<T> = std::result::Result<T, VhdxIoError>;
macro_rules! align {
($n:expr, $align:expr) => {{
if $align > $n {
$align
} else {
let rem = $n % $align;
(($n / $align) + rem) * $align
}
(($n + $align - 1) / $align) * $align
}};
}