mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-21 23:41:15 +00:00
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:
parent
18f1be0fac
commit
134e555c42
@ -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
|
||||
}};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user