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'.
@@ -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
}};
}
