summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Kshevetskiy2025-01-10 08:23:54 +0000
committerDaniel Golle2025-09-23 22:15:33 +0000
commit996dc482a7e88985e25ccb8b6829cbd2ae3e1a53 (patch)
treeae15c10355f5973955798709849d1d5e14f0b27c
parent0725c3d4aa1b7ebec013439cb57fda9dea3f1d5e (diff)
downloadfirmware-utils-996dc482a7e88985e25ccb8b6829cbd2ae3e1a53.tar.gz
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 <mikhail.kshevetskiy@iopsys.eu>
-rw-r--r--src/ptgen.c6
1 files 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 */