From 996dc482a7e88985e25ccb8b6829cbd2ae3e1a53 Mon Sep 17 00:00:00 2001 From: Mikhail Kshevetskiy Date: Fri, 10 Jan 2025 11:23:54 +0300 Subject: [PATCH] ptgen: fix misprint and simplify calculation a bit 2 << ((10 * exp) - 1) is equal to 1 << (10 * exp). This allows us simplify a formula and remove extra if. Signed-off-by: Mikhail Kshevetskiy --- src/ptgen.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ptgen.c b/src/ptgen.c index c7d6bc0..e5fee0d 100644 --- a/src/ptgen.c +++ b/src/ptgen.c @@ -203,10 +203,8 @@ static long to_kbytes(const char *string) return 0; } - /* result: number + 1024^(exp) */ - if (exp == 0) - return result; - return result * (2 << ((10 * exp) - 1)); + /* result: number * 1024^(exp) */ + return result * (1 << (10 * exp)); } /* convert the sector number into a CHS value for the partition table */ -- 2.30.2