You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.0 KiB

From d2f0773eb8482f754d9a7599d26697efcdd25cd6 Mon Sep 17 00:00:00 2001
From: Ondrej Kozina <okozina@redhat.com>
Date: Thu, 9 Aug 2018 10:34:17 +0200
Subject: [PATCH] Remove useless division followed by multiplication by same
base.
---
lib/luks2/luks2_json_format.c | 10 +++++-----
lib/setup.c | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/luks2/luks2_json_format.c b/lib/luks2/luks2_json_format.c
index a0b72ab..4b50f89 100644
--- a/lib/luks2/luks2_json_format.c
+++ b/lib/luks2/luks2_json_format.c
@@ -122,9 +122,9 @@ int LUKS2_generate_hdr(
const char *cipherMode,
const char *integrity,
const char *uuid,
- unsigned int sector_size,
- unsigned int alignPayload,
- unsigned int alignOffset,
+ unsigned int sector_size, /* in bytes */
+ unsigned int alignPayload, /* in bytes */
+ unsigned int alignOffset, /* in bytes */
int detached_metadata_device)
{
struct json_object *jobj_segment, *jobj_integrity, *jobj_keyslots, *jobj_segments, *jobj_config;
@@ -182,11 +182,11 @@ int LUKS2_generate_hdr(
jobj_segment = json_object_new_object();
json_object_object_add(jobj_segment, "type", json_object_new_string("crypt"));
if (detached_metadata_device)
- offset = (uint64_t)alignPayload * sector_size;
+ offset = (uint64_t)alignPayload;
else {
//FIXME
//offset = size_round_up(areas[7].offset + areas[7].length, alignPayload * SECTOR_SIZE);
- offset = size_round_up(LUKS2_HDR_DEFAULT_LEN, (size_t)alignPayload * sector_size);
+ offset = size_round_up(LUKS2_HDR_DEFAULT_LEN, (size_t)alignPayload);
offset += alignOffset;
}
diff --git a/lib/setup.c b/lib/setup.c
index 1a78d2e..61bf3da 100644
--- a/lib/setup.c
+++ b/lib/setup.c
@@ -1601,7 +1601,7 @@ static int _crypt_format_luks2(struct crypt_device *cd,
cipher, cipher_mode,
integrity, uuid,
sector_size,
- required_alignment / sector_size,
+ required_alignment,
alignment_offset,
cd->metadata_device ? 1 : 0);
if (r < 0)
--
1.8.3.1