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