From 134e555c429198b3f9104024020ae455fe397cbf Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Fri, 16 Sep 2022 13:38:08 -0700 Subject: [PATCH] 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 --- vhdx/src/vhdx_io.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/vhdx/src/vhdx_io.rs b/vhdx/src/vhdx_io.rs index ea250c0b2..9fbb9504e 100644 --- a/vhdx/src/vhdx_io.rs +++ b/vhdx/src/vhdx_io.rs @@ -34,12 +34,7 @@ pub type Result = std::result::Result; 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 }}; }